Jump to content

Cipher Challenge School Project

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
AlfredoG4

AlfredoG4

    Newbie

  • Members
  • Pip
  • 2 posts
Hello everyone, my algorithms teacher told us to look for an algorithm solving this problem and explaining it, help is very appreciated as we are not that deep into algorithms yet.


Given a list of 4, 5, 6 ... or 10 integers (between 1 and 100) find the way of getting another integer between 1 and 2000, using only the basic operations: add, substract, multiply and divide. each number in the list can only be used once.

challenge: design, implement and document a solution to the problem, faster than the example program (which I will link later", for sizes between 6 and 10, and that it cannot lose a solution, the program must indicaite all the reachable numbers between 1 and 2000, using the input data.



here is the link, if you need help understanding it just let me know, drop me a message or something

http://dis.um.es/~gi...iles/cifras.exe

thanks in advance!

#2
Luke Bradley

Luke Bradley

    Newbie

  • Members
  • Pip
  • 6 posts
Hi, here's how I interpret what you said. Given a list of 6-10 integers between 1 and 100, you are to make an algorithm that always produces some number between 1 and 2000. The algorithm should be ONTO with the values between 1 and 2000, meaning that that for each value between 1 and 2000, there is some set of 6-10 inputs that will result in that that value.

If my interpretation is correct, this is basically a hashing/hash problem, and that's a good place to start looking for research. (though most hashing uses modulus operator which you say you don't have) Beyond that, I recommend you just break it down. Take one input case (6 numbers in for instance) and forget about the others. Find a way you can make an algorithm that is onto with all positive integers, then look at a way you can guarantee that you can keep that number less than 2000 after that. After the special case, look at the other numbers of inputs.

#3
Luke Bradley

Luke Bradley

    Newbie

  • Members
  • Pip
  • 6 posts
Oh, and above is the academically interesting way, but the quick and dirty way would be just to take the last digit of 4 of the input numbers and use it to construct the number between 1-2000...

#4
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts
Making a modulus is easy. It's just x - ((x / y) * y). Hence you have modulus.