Cody

Recent Activity

1 – 50 of 11,761

Alfonso Nieto-Castanon submitted a Comment to Problem 1917. click away

and btw, your 'x=msgbox('Ok'); while ishandle(x), disp('hello word!'); pause(2); end' code works (meaning that the loop ends when you click on the 'Ok' button) only because of the "pause" command within the loop. Remove that and it will not work at all. Why? you may ask. Well, pause, exactly like drawnow, will force any pending callbacks to be processed (again, this is detailed in "help drawnow"), so, without it, "ishandle" never notices whether you have clicked on the message box button (because the associated button callback function is not yet been executed), or whether you have even closed the entire message box (because the associated figure CloseRequestFcn callback has not yet been executed). Hope this helps clarify

1 hour and 34 minutes ago

David Hill submitted a Comment to Problem 44924. Create State Array for initiating SHA-3-224 Hash

Added some references to the problem description.

2 hours and 24 minutes ago

Alfonso Nieto-Castanon submitted a Comment to Problem 1917. click away

@Rafael. Sorry I am not being very clear, let me start again. The objective of this problem is that players write some code that effectively "clicks on the 'Ok' button" of a message box. In other words, your clickOK() code should have exactly the same effect as if you magically sat on the same computer running the testsuite, saw that message box being created by the testsuite, and immediately used your mouse to click on the 'Ok' button all before your clickOK() function finishes. When you (magically) click on the 'Ok' button, the button callback function will NOT be run immediately. It will actually not be run at all until after the clickOK() function finishes executing entirely, and even then it will not be run just yet. The testsuite will continue running taking priority over your mouse click callback (just like in the infinite loop example) right until the point when the testsuite executes a "drawnow" command. At that point, if you or your function have in fact clicked on the Ok button, the drawnow command will realize that it has a callback pending to be executed and it will run it (see drawnow documentation), which, in turn, will cause the message box to be closed. After that the testsuite will continue running as normal, it will then check that the message box has been closed (note that it was not closed before the drawnow command), and you will "pass" this problem. That's all. Hope this helps

4 hours and 5 minutes ago

Alex submitted a Comment to Problem 46938. Numerical computation of the optimal shooting angle of a catapult

Nice problem. There should be much more problems involving solution of differential equations on Cody. :-)

9 hours and 26 minutes ago

Joseph Martel-Foley submitted a Comment to Solution 3277703

Add a test for multiple matches in the vector.

11 hours and 37 minutes ago

Akrem Hadji submitted a Comment to Solution 3088591

This is a hard one it took me a while to solve it. Thanks God Roman empire has fallen log time ago otherwise I would have no chance to escape decimation.

11 hours and 47 minutes ago

Rafael S.T. Vieira submitted a Comment to Problem 1917. click away

@Alfonso And I've read the documentation of drawnow. It is only a refresh function used at several window managers. Since we are not doing animations, I don't see the point. Button's animation is way too small and fast to need a refresh. Even its other task of processing callbacks is doubtful since It may already have occured (and we cannot guaranteee it dind't). A refresh function only tries to guarantee that after it, everything is already done (and it may or may not be blocking), but it does not guarantee that all callbacks weren't executed before (it may have no work to do).

11 hours and 50 minutes ago

Dyuman Joshi submitted a Comment to Solution 1053996

Aditya Jain Do you have a source for that time limit info?

14 hours and 27 minutes ago

Payam Morsali submitted a Comment to Problem 44319. Write c^3 as sum of two squares a^2+b^2

How on earth the leading solution size is 7? can you please provide it also for us ?

14 hours and 40 minutes ago

Marco Riani submitted a Comment to Solution 1733391

function ans = find_max_sigdec(x) xcol=x(:); x1 = xcol - round(xcol); Decimals=extractAfter(cellstr(num2str(x1)), '.'); max(cellfun(@numel,Decimals)); end

15 hours and 38 minutes ago

Athul Prakash submitted a Comment to Solution 1640004

function b = back_and_forth(n) b = zeros(n); b(:) = (1:n.^2); c = flipud(b); b(:,2:2:size(b,2)) = c(:,2:2:size(b,2)); b=b'; end

18 hours and 48 minutes ago

Rafael S.T. Vieira submitted a Comment to Problem 1917. click away

@Alfonso, try doing instead 'x=msgbox('Ok'); while ishandle(x), disp('hello word!'); pause(2); end' and you will seen as soon as you click on the button the loop stops. Hope this helps. Your code does not work because as Matlab sees it, it is running the same script in the main thread, and there is no reason why the mouse button should take precedence over an infinite loop following the execution order. However, if we do use threads for instance it would be possible to close the dialog-box despite the existence of an infinite loop. My code works because I made it check the status of the dialog box since it is on the same thread. PS: Funny thing, try to click on the X-button from your message box instead of the Ok-button. Some buttons have different priorities, but the mouse click is being executed either way.

21 hours and 51 minutes ago

Rafael S.T. Vieira submitted a Comment to Problem 2409. Find the Connecting Path

This problem needs to have its description improved. It is not clear why some path must prefered over another like on test case #2. Why the fours must cross at the borders when the sevens didn't? Can we only add one 1 per row? and what's the priority of paths?

22 hours and 43 minutes ago

Elizabeth Katulka submitted a Comment to Problem 23. Finding Perfect Squares

Tough one, but interesting

on 18 Oct 2020 at 23:00

Alfonso Nieto-Castanon submitted a Comment to Problem 1917. click away

@Rafael, your PC might generate an interrupt when the mouse is clicked, but that will only tell MATLAB that the mouse was clicked, it is then up to MATLAB runtime to decide what to do with it. And Matlab decides to ignore it for now if some code (in this case the testsuite) is already running until a drawnow command is run, or until the code returns to the Matlab prompt, or until the code issues a waitfor command, etc. (see "help drawnow" for more details). That is NOT the same as if the running code itself (in this case the testsuite) calls the callback function, in which case Matlab runtime will decide to execute that function, not the "ignore it for now" behavior you can expect from a mouse click. If in doubt, try the following: "msgbox('Ok'); while 1, end" and then click on the 'Ok' button. Hope this helps clarify

on 18 Oct 2020 at 21:21

maheshpmk submitted a Comment to Problem 1230. Who is the smartest MATLAB programmer?

688-521=167 Got wrong!

on 18 Oct 2020 at 20:49

Alex submitted a Comment to Problem 46833. Roots, Bloody Roots: part 1/2

Hi, I have tried a first solution. Since I see only the hash value of the correct solution and not the solution itself, I am not sure how to finalize my code.. So, some questions: (1) where exactly is the zero angle? The text says on the real line (which should be to the right?) the picture suggests to the bottom (isn't red equal to zero angle in HSV?) (2) what exactly is beta? The text says "norm" --> I assumed Euclidean norm. is this correct? (3) does the test suite account for numerical noises due to different implementations, or is it just a hash of the reference solution? Thanks. :-)

on 18 Oct 2020 at 19:48

KATTA PRATYUSHA submitted a Comment to Problem 558. Is the Point in a Triangle?

nice one but it took so much of time

on 18 Oct 2020 at 17:02

Akrem Hadji submitted a Comment to Solution 2858585

This is the best problem ever (y)

on 18 Oct 2020 at 16:48

Gautam Rawat submitted a Comment to Solution 3264283

Are these problems only for getting a Badge? ????

on 18 Oct 2020 at 14:44

Daniele Certini submitted a Comment to Solution 3263723

Nice problem!

on 18 Oct 2020 at 13:52

Gautam Rawat submitted a Comment to Problem 2678. Find out sum and carry of Binary adder

Some of the top solutions have made a solution only for test cases, This should be fixed.

on 18 Oct 2020 at 13:37

Rafael S.T. Vieira submitted a Comment to Problem 1917. click away

@Alfonso, I disagree. Clicking on the Ok button is the same thing as calling the callback function because when we click on it with a mouse button, it generates an interrupt request which causes it to be executed almost immediately https://en.wikipedia.org/wiki/Interrupt_request_(PC_architecture). This interruption tells the PC to stop everything that he is doing to handle our request, and unless some higher priority task is running, the mouse or keyboard will take the lead. I imagine that this was created like so to increase response time: so we don't have to wait for some process to finish to interact with our pcs. Rigorously, even calling a function does not guarantee it will be executed immediately, the same way that clicking on a button that calls it will not; however, the latter will probably have a higher priority. That's why we can use shortcut keys like Ctrl+Alt+Del or Command + Option + Esc to stop some slow running process (some function running for way too long). Please, check whenever possible the solutions for your problem, including the leading one. I will try once again to meet your requirements, but they are not the regular operation of a mouse click.

on 18 Oct 2020 at 5:16

Rafael S.T. Vieira submitted a Comment to Problem 46873. Sum of terms in a series 2 (★★★)

Please, do not use isqual with floats, instead use abs(x1-x2) < 1e-10 for instance. A number like 0.1 is infinite and periodic in base 2.

on 18 Oct 2020 at 4:28

Akrem Hadji submitted a Comment to Problem 980. Unique values without using UNIQUE function

The link forward to MATLAB stable releases not to unique function documentation!!

on 17 Oct 2020 at 16:49

Akrem Hadji submitted a Comment to Problem 972. Set a diagonal

Please add a precision threshold for floating numbers. Sometimes I get results with an error ~ e-17 close, but still not accepted.

on 17 Oct 2020 at 16:42

Yang Liu submitted a Comment to Solution 3252193

Remember to use () & [] correctly.

on 17 Oct 2020 at 15:09

Johanna Richter submitted a Comment to Problem 44376. The sliding puzzle: 3D

I am actually giving up :( tried a lot......

on 17 Oct 2020 at 10:59

Dyuman Joshi submitted a Comment to Problem 45246. Count digits

@Asif You are right in the sense that one needs to find an alternate way However, I guess MATHWORKS need to work on this as there is a low cost solution available to the problem rendered useless with max array size

on 17 Oct 2020 at 8:36

Rafael S.T. Vieira submitted a Comment to Problem 46808. F.R.I.E.N.D.S

It's cool to create some fun problems once in a while, but to flood Cody with them is not, please, try to create something more challenging. Or else someone may think that you are trying to cheat at the Cody contest.

on 16 Oct 2020 at 21:52

Rafael S.T. Vieira submitted a Comment to Problem 46028. Paint it black!

Thank you, Jeremy. I'm glad you liked it.

on 16 Oct 2020 at 21:48

kaatil_coder submitted a Comment to Problem 615. Nilpotent matrix

@Ling Liang , take some tolerance while checking the equality of eigen value with zero.

on 16 Oct 2020 at 21:33

Rafael S.T. Vieira submitted a Comment to Problem 46778. PIN code II

Please, do not use isequal with floats, use (a-b) < tol.

on 16 Oct 2020 at 21:32

Rafael S.T. Vieira submitted a Comment to Problem 543. deconvolution

This problem needs to have its description fixed. It should be "Is the polynomial represented by (v/w) an integer for any integer x except for the roots of w? if the integer x is a root of w, we will have a NaN, which is the case for the test case #1 and the value x=1 for instance.

on 16 Oct 2020 at 19:12

Rafael S.T. Vieira submitted a Comment to Problem 551. Have you seen any Spindromes recently?

The definition of spindromes is not really clear. But basically it seems that we must look if there is a repeating pattern, if we found one, then the sequence is not a spindrome. On the other hand, AAAXXXAAA should not be a spindrome imho, since it is a repeating pattern AAAXXXAAAAAAXXXAAAAAAXXXAAAAAAXXXAAA ... so we have to limit the test to half of the list size which means AAAXX | XAAA is apparently a spindrome. However BBBXXXBBBXXX is not a spindrome, since we would have BBBXXX | BBBXXX.

on 16 Oct 2020 at 17:57

Nikolaos Nikolaou submitted a Comment to Problem 43738. Negative without '-'

Thanks goc :)

on 16 Oct 2020 at 17:29

Rafael S.T. Vieira submitted a Comment to Problem 321. polar inertia

The polar inertia is the sum of the squared distances of all points from the origin. https://en.wikipedia.org/wiki/Polar_moment_of_inertia

on 16 Oct 2020 at 16:59

Rafael S.T. Vieira submitted a Comment to Problem 150. chirp again

For the moment, this has become a hacking problem, until the author fixes it.

on 16 Oct 2020 at 16:17

Rafael S.T. Vieira submitted a Comment to Problem 150. chirp again

The test suite needs to be updated since the function chirp is no longer available. Moreover, most solutions use chirp, which was not recommended at the problem description and would render them false. On the other hand, the problem description also needs to be updated, it is not clear what the function "rise smoothly like an aircraft taking off from ground" is . Anyway, the few solutions that don't use chirp use sin, which is probably the right way to go. However, looking at the documentation of chirp, one may find several different functions to achieve a possible result and none of them is sin.

on 16 Oct 2020 at 16:16

Katelyn Lopez submitted a Comment to Problem 2017. Side of an equilateral triangle

Nice

on 16 Oct 2020 at 15:55

keqin zhao submitted a Comment to Solution 1281786

Great!

on 16 Oct 2020 at 13:02

SIBI CHAKARAVARTHY R submitted a Comment to Solution 1687367

cheating

on 16 Oct 2020 at 12:46

Monica R submitted a Comment to Solution 3234673

Compare the number in current index with the number in next index. If it is less than or equal to zero return false.

on 16 Oct 2020 at 10:44

Rafael S.T. Vieira submitted a Comment to Problem 2029. Convert vector datasets to plot with imagesc instead of scatter

The function roundn is no longer supported by Cody, please update the test suite to round(x/10^e)*10^e.

on 15 Oct 2020 at 15:38

Rafael S.T. Vieira submitted a Comment to Problem 2028. Magic Concentric Circles

The test case #5 in is not a magic circle because its radii are not equal (column 3 should be made of two 69s as are all the others, but instead they are 82 and 56). Please fix the test suite whenever possible.

on 15 Oct 2020 at 15:04

Steve Eddins submitted a Comment to Problem 250. Project Euler: Problem 10, Sum of Primes

As suggested by David Verrelli on 15-Dec-2017, I have edited the problem statement to reconcile it with the test suite. For everyone's reference, the original problem statement was: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below the input, N. But that problem statement didn't match one of the test suite cases. Since I didn't change the test suite, the solutions did not need to be rescored.

on 15 Oct 2020 at 14:33

Dyuman Joshi submitted a Comment to Problem 1591. Find the minimum element of the matrix

Fix the function handle in the last case ASAP

on 15 Oct 2020 at 14:32

Rafael S.T. Vieira submitted a Comment to Problem 46746. Volume of a truncated cube

Tip: the 8 tetrahedra at the cube corners are not regular, but they have equilateral triangles as base. PS: Kudos for the author, nice figures. It's so rare to find a problem with graphics at Cody. And sometimes a picture conveys much more than a long text.

on 15 Oct 2020 at 13:12

Muhammad Akmal Afibuddin Putra submitted a Comment to Solution 3218663

tf = false; if mod(n,2) ~= 0 tf = true; end

on 15 Oct 2020 at 9:49

Monica R submitted a Comment to Solution 3216523

simply use pythagoraen theorem

on 15 Oct 2020 at 5:36

1 – 50 of 11,761