-2
\$\begingroup\$

This might be a very basic question in terms of math,

x % constant = x_modulus

(x + some_number) % constant = y_modulus

Given the value of x_modulus, y_modulus, (x + some_number) and constant(common in both), output the value of x itself based on these values.

\$\endgroup\$
  • \$\begingroup\$ Are you asking this question because you don't know, or because you want us to write programs that will input these numbers and output x? \$\endgroup\$ – Wezl May 4 at 14:16
  • \$\begingroup\$ I am asking becase I really don't know in terms of math, how to correlate all these values together. I don't want the complete program, just rough steps would be enough. \$\endgroup\$ – Tejas Sarade May 4 at 14:19
  • 5
    \$\begingroup\$ Then maybe you should post this on the math stackexchange, where you will be very likely to get an answer. On code golf, you would get answers of short programs that could solve your problem but not always direct answers. See why this question was closed. \$\endgroup\$ – Wezl May 4 at 14:23
  • 1
    \$\begingroup\$ Just as a side note, the value of some_number is the absolute difference between x_modulus and y_modulus, which is in turn x's distance with the closest multiple of constant larger than x. Therefore it's impossible to find what exactly is the value of x. That greatly simplifies the question. \$\endgroup\$ – user92069 May 4 at 14:28
2
\$\begingroup\$

05AB1E, 1 byte

Finds the smallest possible value of all values of x, takes input as some_number, constant, x_modulus, y_modulus

α

Try it online!

Explanation

Here are my observations:

  • The value of some_number is the absolute difference between x_modulus and y_modulus

  • The above value is in turn x's distance with the closest multiple of constant larger than x.

Therefore it's impossible to find what exactly is the value of x. That greatly trivializes the question into a simple absolute difference between some_number and constant.

The code itself is just absolute difference, I don't feel like explaining it. :D

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ What does this do? :) \$\endgroup\$ – the default. May 4 at 14:34
  • \$\begingroup\$ @mypronounismonicareinstate This solves the question. :) \$\endgroup\$ – user92069 May 4 at 14:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.