It looks like you're using an Ad Blocker.

Thank you.

Some features of ATS will be disabled while you continue to use an ad-blocker.

# Need 4 Integers That Give Unique Totals

page: 1
0
share:

posted on Feb, 23 2017 @ 12:47 PM
This is not for a school project or anything important, I'm just an amateur video game hobbyist. So here's the deal...

I'm trying to design a top-down view of a city (think Grand Theft Auto 1) and I want to connect road pieces based on randomly generated road maps.

I only need the roads to connect at right angles, so they will only be going in the 4 cardinal directions.

In order for my program to know which piece (curves, straights, intersections, etc) to attach to its neighbor, I need to assign one of 4 identifying numbers - one for a neighboring piece of road to the North, one for South, one for East and one for West.

However, in order for this to work, no 2 totals (ranging fom 2 to four digits) can repeat against another total.

For example 10, 20, 30 and 40 don't work because 10+40 as well as 20+30 both equal 50.

So what are 4 magical digits that won't give repeating totals?
Any takers? =)

posted on Feb, 23 2017 @ 12:49 PM

originally posted by: DeReK DaRkLy
This is not for a school project or anything important, I'm just an amateur video game hobbyist. So here's the deal...

I'm trying to design a top-down view of a city (think Grand Theft Auto 1) and I want to connect road pieces based on randomly generated road maps.

I only need the roads to connect at right angles, so they will only be going in the 4 cardinal directions.

In order for my program to know which piece (curves, straights, intersections, etc) to attach to its neighbor, I need to assign one of 4 identifying numbers - one for a neighboring piece of road to the North, one for South, one for East and one for West.

However, in order for this to work, no 2 totals (ranging fom 2 to four digits) can repeat against another total.

For example 10, 20, 30 and 40 don't work because 10+40 as well as 20+30 both equal 50.

So what are 4 magical digits that won't give repeating totals?
Any takers? =)

Prime numbers?

posted on Feb, 23 2017 @ 12:51 PM

Hmm.. I'll check into it unless someone can beat me to it.

posted on Feb, 23 2017 @ 12:53 PM
How far out(combinations) and in what way(addition, multiplication, etc) are these numbers not supposed to give repeating totals?

posted on Feb, 23 2017 @ 12:57 PM

3,7,13,23

I think this works for what you are trying to do, as long as you are just adding any two and not adding to the results of the original two added together.

posted on Feb, 23 2017 @ 01:02 PM
Sorry, let me clarify

I have to add anywhere from 2 to 4 of the digits:

a+b
a+b+c
a+b+c+d
a+b+d
a+c
a+c+d
a+d
b+c
b+c+d
b+d
c+d

did i forget any?
Regardless, none of the totals should match.
edit on 23-2-2017 by DeReK DaRkLy because: (no reason given)

posted on Feb, 23 2017 @ 01:10 PM
It's a trick. There is no solution. He's trolling us. I can't prove it yet, but it just feels like we are being fooled.

posted on Feb, 23 2017 @ 01:12 PM

originally posted by: graysquirrel
It's a trick. There is no solution. He's trolling us. I can't prove it yet, but it just feels like we are being fooled.

LOL... how are you fooled if you already think it's a trick?

posted on Feb, 23 2017 @ 01:19 PM
Look at card dealing algorithms and adapt shall we say 1 in 4 is just the same as 1 in 52.

This was basic 101 in the old days and should be pretty easy to code and having had a few brews I won't go much further till probably the afternoon/evening in the US as i've got to take my mum shopping and do all sorts of other stuff.

There are pretty much well sorted methods of picking a value with very little need for repetition if you take a google.

posted on Feb, 23 2017 @ 01:20 PM
They way this is normally done is with bit flags, and with bitwise operations you determine which flags are turned on. This is done all the time in C++ programming. In a simpler way you can use any language to do this. Give each item a number:

1 = A
2 = B
4 = C
8 = D

Given any number between 0 and 15, you can determine which 'bits' are set. For example, say the number is 13. Now start subtracting numbers from highest to lowest. Can you subtract 8 from 12? Yes, then D is turned on. You are left with 5. Can you subtract 4 from 5? Yes, so C is turned on. You are left with 1. Can you subtract 2 from 1? No. So B is turned off. Can you subtract 1 from 1? Yes, so A is turned on.

If its 0, all are turned off. If it's 15, all are turned on.

posted on Feb, 23 2017 @ 01:23 PM
a=3
b=5
c=7
d=11

a+b 8
a+b+c 15
a+b+c+d 26
a+b+d 19
a+c 10
a+c+d 21
a+d 14
b+c 12
b+c+d 23
b+d 16
c+d 18

Does that work?

posted on Feb, 23 2017 @ 01:26 PM
So for your example, if A = 1, B = 2, C = 4, D = 8, you would have these totals:

a+b = 3
a+b+c = 7
a+b+c+d = 15
a+b+d = 11
a+c = 5
a+c+d = 13 (this is the one I gave above)
a+d = 9
b+c = 6
b+c+d = 14
b+d = 10
c+d = 12

posted on Feb, 23 2017 @ 01:27 PM
Prime number will work.

Odd + Odd = Even

Prime1, P2, P3, P4 will never add to the same Even number if, P1 =/ P2 =/ P3 =/ P4 (and all > 0)

Binary will also work. If you do it as a 4-bit number (1000, 0100, 0010, 0001) it is just the backwards of primes. You end up with a unique number in all combos.

Good luck! Hope your game works out!!
edit on 23-2-2017 by TEOTWAWKIAIFF because: hidden bbcode maybe

posted on Feb, 23 2017 @ 01:27 PM

As a programmer, I would say what you are looking for are "bits", i.e., binary digits.

0x0000 = 0
0x0001 = 1
0x0010 = 2
0x0100 = 4
0x1000 = 8

You can add these together to get any combination.

Fro example, 0x1000 + 0x0001 = 0x1001 = 9

posted on Feb, 23 2017 @ 01:28 PM

I like it, but having trouble wrapping my head around it.. this is why I'm an amateur programmer. LOL

posted on Feb, 23 2017 @ 01:30 PM

originally posted by: Olivine
a=3
b=5
c=7
d=11

a+b 8
a+b+c 15
a+b+c+d 26
a+b+d 19
a+c 10
a+c+d 21
a+d 14
b+c 12
b+c+d 23
b+d 16
c+d 18

Does that work?

AWESOME!!! Thank you.

Thanks to the others for the bit about bits.. I have much to learn!

posted on Feb, 23 2017 @ 01:35 PM

originally posted by: CountZero00
So for your example, if A = 1, B = 2, C = 4, D = 8, you would have these totals:

a+b = 3
a+b+c = 7
a+b+c+d = 15
a+b+d = 11
a+c = 5
a+c+d = 13 (this is the one I gave above)
a+d = 9
b+c = 6
b+c+d = 14
b+d = 10
c+d = 12

That works too! Great!!

posted on Feb, 23 2017 @ 01:39 PM
A good bit of comp-sci is learning about various number bases such as binary/octal/hex/decimal and how to mangle them to give a result that is actually worth something.

That maths of random numbers gives a whole different conversation and unless you have one of those particle decay generators it could get messy.

posted on Feb, 23 2017 @ 01:41 PM

originally posted by: Maxatoria
A good bit of comp-sci is learning about various number bases such as binary/octal/hex/decimal and how to mangle them to give a result that is actually worth something.

That maths of random numbers gives a whole different conversation and unless you have one of those particle decay generators it could get messy.

Indeed, my math is so weak I have to reverse engineer everything... instead of applying math to real-world situations, I find myself applying real world situations to math instead somehow!

posted on Feb, 23 2017 @ 02:40 PM
To check the bits you just use logical AND on the bit and with the bit set for the value being tested..

new topics

top topics

0