|
Found the error in my ways
It now works.
static int FindLastManStanding(int startingPosition = 2)
{
int retVal = -1;
bool lastWasKilled = false;
List<int> dead = new List<int>();
if (startingPosition == 1)
captures.RemoveAt(0);
int max = captures.Max();
for (int i = 1; i <= captures.Count; i++)
{
if (i % 2 == 0)
{
if ( max == captures[i - 1])
lastWasKilled = true;
dead.Add(captures[i - 1]);
}
}
dead.ForEach(x => captures.Remove(x));
startingPosition = lastWasKilled ? 2 : 1;
if (captures.Count == 1)
retVal = captures[0];
else
retVal = FindLastManStanding(startingPosition);
return retVal;
}
|
|
|
|
|
Khaaaaaaaan!
The language is JavaScript. that of Mordor, which I will not utter here
I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript.
|
|
|
|
|
"...to the last I grapple with thee; from hell's heart I stab at thee; for hate's sake I spit my last breath at thee."
Don't think Ahab was too happy really...
|
|
|
|
|
OriginalGriff wrote:
"...to the last I grapple with thee; from hell's heart I stab at thee; for hate's sake I spit my last breath at thee." |
That quote always reminds me of the Simpsons!
|
|
|
|
|
Herman Melville for me, I'm afraid!
|
|
|
|
|
|
I'll see you and raise![^]
speramus in juniperus
|
|
|
|
|
Is this the shortest solution?
var switcher = true;
var range = Enumerable.Range(1,1000).ToList();
while( range.Count > 1)
range = range.Where(x => (switcher = !switcher) == false).ToList();
range.Dump();
|
|
|
|
|
Keeping up with today's trend, let me ask,
To those who are willing to do this task,
Given digits numbered one to nine,
Only positive and without a minus sign,
Not repeating a digit find a two number set,
The product of which none other can offset.
|
|
|
|
|
Not really clear on what "The product of which none other can offset." means, but here's my go.
I'm assuming it means won't result in a different number when multiplied by another. 3 and 7 gives us ten. One by Zero leaves us with 0.
3 + 7 --> 10
1 * 0 --> 0
|
|
|
|
|
I guess I did not do too well with the rhyme.
I just mean the largest product.
|
|
|
|
|
Perhaps not perfectly, but still pretty bloody impressive. (to an aussie )
Interesting question. Bookmarked for future fun.
Thanks.
|
|
|
|
|
Poetry + Maths = MehGerbil Logging Out
|
|
|
|
|
97531 * 8642
speramus in juniperus
|
|
|
|
|
|
... no, just sums.
speramus in juniperus
|
|
|
|
|
just sums for some, awesome for some other..
|
|
|
|
|
|
Nagy Vilmos wrote: 97531 * 8642
Sorry mate, I'd like one of those votes back, on account of your suggestion not being the answer..
I can go at least 1,111 higher.
97531 * 8642 = 842,862,902
9753 * 86421 = 842,864,013
I wonder if there's a published theorem on the matter. Your solution probably wouldn't have occurred to me. It seemed perfect upon first look. It was only now watching an old doco that I found myself considering the benefit/loss of taking a digit from one side and adding it to the other. But this was a mere chance discovery, it certainly wasn't systematic. The curious value of the difference between the two results makes me wonder even more. (Damn you Sandoz & Albert Hoffman - this doco is a trip! )
|
|
|
|
|
Well you can at least temporarily award the points to me.
With 87431 * 9652 = 843884012, I'm 1019999 higher than you.
Politicians are always realistically manoeuvering for the next election. They are obsolete as fundamental problem-solvers.
Buckminster Fuller
|
|
|
|
|
Sure, but don't get too attached to them, I'm going to hold them again for a bit, if you don't mind.
87531 * 9642 = 843,973,902 (another 89,890 higher again)
|
|
|
|
|
I don't mind.
Politicians are always realistically manoeuvering for the next election. They are obsolete as fundamental problem-solvers.
Buckminster Fuller
|
|
|
|
|
87431*9652
Politicians are always realistically manoeuvering for the next election. They are obsolete as fundamental problem-solvers.
Buckminster Fuller
|
|
|
|
|
I am an old dog, that still like to produce small code that doesn't require a huge framework or any runtime.
I would like to know if there are still low level SDK programmers floating around here?
I am asking this because i am porting my PowerBASIC graphic libraries (WinLIFT/GDImage) to C++, and i am not sure of the best setting to produce the smallest Visual Studio 64-bit DLL without any external dependencies.
...
Patrice Terrier
www.zapsolution.com
|
|
|
|
|
Why do you need to be as small as possible in the world of 64 bits?
Regards,
Rob Philpott.
|
|
|
|