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?
Roshan
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
olli
Roshan
olli
olli
checking every number in the range of min values will eventually yield the correct result
Roshan
Manav
Manav
^ this would evaluate as you said, checking all ranges
Roshan
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?
Roshan
ברני
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).
Roshan
Георгий
Low effecient
Mino
I don't get it
olli
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
For simplicity I had provided another snippet, check that for debugging...
olli
Roshan
I also tried to change everything to long long int data type. Still I don't know
Roshan
Well is it due to the compiler closing the program as it might be running for long time?
Roshan
Manav
Manav
They signed up, used your code, all of the test cases pass. \(_-_)/
Roshan
WTH
Roshan
Really!
olli
Roshan
olli
Is it?
Basically, it's not the compiler closing it tho but rather the environment your code executes in
Roshan
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++
Manav
Manav
Your problem seemed interesting so I offered some help, that's it
Roshan
M.Khorram
Mino
I want only translate it in C++
Manav
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
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