shivamp_95's blog

By shivamp_95, history, 3 months ago, In English,

recently there was a question to make program by solving the sequence-pattern given in input and output... please try to find it ,and help me if you can .... for every two integer input ,an output was given:

input
(1 4)
(2 3)
(4 10)
(7 10)
(8 100)
(200 300 )
(255 275)
output 5 5 12 7 1043 4048 1060

respectively how can input and output be related here, to each other????

edit : i would like to thank ChasmOfSarcasm for his message ,thanks for solving it .

 
 
 
 
  • Vote: I like it
  • -13
  • Vote: I do not like it

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Ain't nobody got time for that.

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I could not come up with a solution after looking at it , I am trying to think now but am tired.But, how do we know you are not just typing a random list of numbers and trolling us?

»
3 months ago, # |
Rev. 2   Vote: I like it +7 Vote: I do not like it

Here's simple program which solves given task:

#include <iostream>
#include <random>

usnig namespace std;

int main()
{
  int x, y;
  mt19937 rnd;

  while(cin >> x >> y)
    cout << rnd() % 5000 << endl;

  return 0;
}
  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    So what did you sacrifice to become master?

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it +9 Vote: I do not like it

      5 stacks of yellow dye in Minecraft.

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    this code is not working ?? i think i was unable to interpret problem correctly .. here is its link
    https://www.hackerearth.com/codearena/ring/14d2717/

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    bro ,your solution is wrong , i got the correct answer from ChasmOfSarcasm ... here output is the sum of prime numbers between input range [a b] ... thanks for trying it and giving your time for my question ...

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it +4 Vote: I do not like it

      Did you even like, read the code?

      • »
        »
        »
        »
        3 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        yes , he is using random values and taking its mod with 5000 ..., i too initially thought to do this as i was unable to build any connection between input and output . but it failed ....

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      can you please tell us how we can also learn to make such observation? I could not see it

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You have to be more specific on what type of relationship you're looking for. Any set of input and output values can be fitted perfectly by some polynomial. For example, I could say that the output is (197121089224141 x^5)/14824459483725929637600 - (9060603386308189 x^4)/570171518604843447600 + (26660326915496837687 x^3)/4941486494575309879200 - (1422560370026178478451 x^2)/3706114870931482409400 + (4867386451591739811563 x)/741222974186296481880 - 3706498869439340167/196090733911718646 where x is the sum of the two inputs.

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How did you find this polynomial?

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    so ,you mean ,you are trying to fit all given sample test in a polynomial equation , but then it will fail at system test .... if we do it without any logic ...

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      That isn't supposed to be a solution to the problem. The point is that "find a relationship between a given set of inputs and outputs" isn't really a good question because there will always be many possible relationships that match any set of input and outputs if we don't restrict the type of relationship we're looking for.

      • »
        »
        »
        »
        3 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I got you bro , but here i got solution ( credit : ChasmOfSarcasm)..... output is sum of prime numbers between given input range [a b] ....

        btw ,developing a polynomial without knowing all test cases is extremely tough.

        we need to observe the repeated pattern ,after your response i tried to make graph between input a ,input b and output in 3-d but it was very hard to observe any pattern except if we don't know prime numbers are involve there . also it will form a non continuous discrete points plot.. there also main task will be to observe & interpret the pattern between a and b which result output in z axis.. it is very tough to know it ,without knowing value of function between a and b at various point.

        yes i fully agree with you, there may be some other possibility to solve it .i would love to know how you formed above equation and by what logic ,you decided its parameter ....
      • »
        »
        »
        »
        3 months ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        i observed your link , now i got to know ,what you were saying ... thanks for it ,your logic is definitely correct. there are multiple answer to it .

»
3 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

This is the link of that problem https://www.hackerearth.com/codearena/ring/14d2717/
i think i was unable to interpret problem correctly ,please have a look at it