Manav
In your case your implementation is correct. Your code is doing what you want it to, but your algorithms is incorrect. So how do you expect it to pass all cases?
Manav
The app does not check for code, it checks the output 😕
Lemme simply it for you. Imagine you are asked to multiply two numbers, So you write code like yhis: void multiply(int num1, int num2) { return num1 + num2; } And have these test cases multiply(2,2) == 4 multiply(1,1) == 1 mulitply(0,1) == 0 Out of these three you pass 2 of these. Does it mean your algorithm (adding the two numbers instead of multiplying them) is correct? NO
Manav
How do you define correctness? Because his algorithm works, it's just too slow
Because his test cases evaluate to false, and also I could list out infinitely many cases in which it will fail.
olli
checking every number in the range of min values will eventually yield the correct result
Manav
please list one that fails for his updated version
You'll have to wait a bit, I am outside at the moment
Manav
checking every number in the range of min values will eventually yield the correct result
I don't think he's doing that, he is calculating max of min values
Manav
^ this would evaluate as you said, checking all ranges
Roshan
I don't think he's doing that, he is calculating max of min values
I am calculating the maximum of minimum values to start the algorithm with that minimum value
olli
I don't think he's doing that, he is calculating max of min values
From his code find the min of mins books = min[0]; // dummy init for (int i = 0; i < N; i++) { if (books > min[i]) { books = min[i]; } } find the max of mins max_of_min = min[0]; for (int i = 0; i < N; i++) { if (max_of_min < min[i]) { max_of_min = min[i]; } } Check all values while (books <= max_of_min) {
Manav
🤦‍♂️, I guess giving you test cases which evaluate to false will be better. That'll probably help you understand what you're doing incorrectly
Roshan
Manav do you mean I have to set those ranges in a number line and find out a range that is common to all?
Manav
It's too much a tedious task to do immediately. You'll have to give me some time
ברני
Can anyone tell me about a very good compiler for phone?
ברני
And for c?
Roshan
And for c?
Never used C but it will support I guess
ברני
OK I'll try ty
Mino
Is it possible able to do an function_handle in C++? ''hvsd = @(x) [1*(x == 0) + (x > 0)]'' (this code was written on mathlab) (I thought with operator logic).
Георгий
Try catch?
Very bad option
Георгий
Low effecient
Mino
I don't get it
Mino
Could you explain me that code ?
olli
Could you explain me that code ?
you can call func pass it an int parameter named x and this function will return the result of 1 * (x == 0) + (x > 0); And you can pass func around (basically as every other freestanding function) What are you trying to do?
Mino
I need to traslate an code, mathlab—> C++, because I'm using OP4520 FPGA, that receive only code with C++. I must send the signal in my generator turbine.
Mino
I need to create this function
Mino
this is the code, very easy. But I have never write code with C++
Mino
I want to learn to write something. This is the first code, but I'll have to traslate something else
Manav
@Roshan_Pradhan1098 I saw your code, it looks correct. I misread min with max. It shouldn't evaluate all the test cases. So what's the problem?
Roshan
@Roshan_Pradhan1098 I saw your code, it looks correct. I misread min with max. It shouldn't evaluate all the test cases. So what's the problem?
🙏 Can you please give the test cases which will result incorrect output. Else why would I be getting 1/3 test cases correct?
Manav
🙏 Can you please give the test cases which will result incorrect output. Else why would I be getting 1/3 test cases correct?
You shouldn't, its probably quite slow. Or you have overflow problems. N can ranges from 1 to 10000 if I remember correctly
Roshan
For simplicity I had provided another snippet, check that for debugging...
Roshan
I also tried to change everything to long long int data type. Still I don't know
Roshan
this one 2 1 999999999 999999999 999999999
May crash... I fear if your computer can handle please try...
Roshan
Well is it due to the compiler closing the program as it might be running for long time?
Roshan
Manav
took a while to sign up... but looks like it worked ¯\_(ツ)_/¯
Uhh, I scrolled up to understand this whole situation lol. It works.
Manav
They signed up, used your code, all of the test cases pass. \(_-_)/
Roshan
WTH
Roshan
Really!
olli
Is it?
Basically, it's not the compiler closing it tho but rather the environment your code executes in
Mino
How I can write ''[0:dt:(SimTime)]'' on C++ ? dt time interval and SimTime is equal 10 such as.
Mino
t=[0:dt:(SimTime)];
Roshan
Manav, do you've to say anything tho?😕 You were preparing inputs... Weren't you?
kodes
Please suggest some ideas for creating custom libraries using c++
Roshan
Nope, I am outside as I said previously.
Ok I'll be off for sometime DM me when made....
Manav
Ok I'll be off for sometime DM me when made....
You seem to be mistaken, I am not your personal problem solver
Manav
Your problem seemed interesting so I offered some help, that's it
Roshan
Your problem seemed interesting so I offered some help, that's it
Yeah so, is it not appropriate to DM me only the input? Well that's it..
Manav
Yeah so, is it not appropriate to DM me only the input? Well that's it..
Nope, you don't dictate what I do on my own time. Also olli already gave you the edge test cases that doesn't work. Your algorithm as I see it looks correct. You check for the number of happy students for each minimum books. Then just return the one which has the most students happy.
Mino
I want only translate it in C++
Manav
As you wish. You also tried to help me - Thank you for that!
Heh, not really but if it did help you, you're welcome
Mino
I want resolve the equation with that method
M.Khorram
I want resolve the equation with that method
Translation is easy but, you can it with/without defining class you need to decide about the output in plot also, you probably, need to know what you want to do with the probably memory consuming i_a
Mino
I want translate the code, export the plot and import it on mathlab for view the difference between two code. I want to overlap these 2 plot. One with code mathlab and one with code C++
Mino
The code is finished like this, I want only export the plot
Mino
In the as easy as way possible
M.Khorram
The project is far more than code conversion from Matlab to C++ You need to transfer the data to a desktop and then to Matlab. I suggest to convert it as you planned. But, be aware that transferring data is the main issue
Mino
Cannot I export the plot directly ? Or Do I need to export the data and that with these I must plot it on mathlab ?
M.Khorram
Cannot I export the plot directly ? Or Do I need to export the data and that with these I must plot it on mathlab ?
You need develop the FPGA code to send data to your computer via either serial port or rj45. And , you need to develop a code in your desktop to receive the data and reformat it (for endianness, and other things). the code on your computer could be written in either Matlab, or other programming languages such as C++ and C#
M.Khorram
Finally, you can plot the received data
Mino
Ok, But these are the next problems. Now my first problem is learning the language.
Mino
I want to traslate this code in C++, and overlap 2 plots.
Mino
I want to view the difference between that 2 plots.
Mino
Now, my problem is how i can write what code in C++
Mino
then, I will see the next problem, step by step