Topic awaiting preservation: Need help with a math trick question |
|
---|---|
Author | Thread |
Bipolar (III) Inmate From: you tell me |
posted 09-16-2010 07:06
Hi guys, I've come face to face with a math problem and can't seem to get over it for the last couple of days. It goes like this: |
Paranoid (IV) Inmate From: Florida |
posted 09-16-2010 09:14
You crossposter, you. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 09-16-2010 09:35
the way you describe it, I can't follow how this machine is supposed to work. Does it add digits or numbers? |
Maniac (V) Inmate From: San Antonio |
posted 09-16-2010 19:08
I think he means numbers, although digits would work too, you'd just be limited by what base you're working in (base 10 gives you a max of N=9 {1,2,...,9}, base 16 gives you a max of N=15 {1,2,...,F}). code: int[] numbers = {2, 3, 5, 2, 1, 4}; int N = numbers.Count -1; // 5 (Count includes the duplicate) int sum = 0; for(int i=0; i<=numbers.Count; i++) { sum += numbers[i]; sum -= i; }
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 09-17-2010 10:23
ok, if you have the n+1 numbers it's trivial |
Maniac (V) Inmate From: San Antonio |
posted 09-17-2010 20:41
quote:
quote:
|
Bipolar (III) Inmate From: Cranleigh, Surrey, England |
posted 09-29-2010 00:17
Hmm, the problem does seem a tad odd. I would say, up to rearrangement, you have a sum of the form 1+...+N+x, and you want x. code: greatest possible sum for N = 1+...+N+N < 1+...+(N+1)+1 = least possible sum for N+1
code: javascript:numberToTest=13;for(n=1,m=numberToTest;(m-=n)>n++;){};alert(m?m:'Impossible Sum')
|