no iterations
-
MyGodItsFullOfStars
BestSoFar :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
-
Sorry, rejected by at least a dozen FxCop rules. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
-
MyGodItsFullOfStars
:laugh: Got my vote.
-
Can you come up with an appropriate name for this method:
public static string[] xyz(int n) {
if (n<1) throw new ArgumentException("n must be greater than zero");
return new string('*', (int)Math.Round((Math.Pow(0.5+Math.Sqrt(1.25), n)-Math.Pow(0.5-Math.Sqrt(1.25), n))/Math.Sqrt(5))).Replace("*", ".*").Substring(1).Split('.');
}PS: triggered by an actual programming question (which looked like homework). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
-
Can you come up with an appropriate name for this method:
public static string[] xyz(int n) {
if (n<1) throw new ArgumentException("n must be greater than zero");
return new string('*', (int)Math.Round((Math.Pow(0.5+Math.Sqrt(1.25), n)-Math.Pow(0.5-Math.Sqrt(1.25), n))/Math.Sqrt(5))).Replace("*", ".*").Substring(1).Split('.');
}PS: triggered by an actual programming question (which looked like homework). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
HereBeDragons(n)
;P Or even better:uβerπ(n)
:laugh: EDIT: If you can't read that, it says uBer(pi) -
Can you come up with an appropriate name for this method:
public static string[] xyz(int n) {
if (n<1) throw new ArgumentException("n must be greater than zero");
return new string('*', (int)Math.Round((Math.Pow(0.5+Math.Sqrt(1.25), n)-Math.Pow(0.5-Math.Sqrt(1.25), n))/Math.Sqrt(5))).Replace("*", ".*").Substring(1).Split('.');
}PS: triggered by an actual programming question (which looked like homework). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
How about:
private static readonly double WhatDoesThisMean = 0.5 + Math.Sqrt(5); private static readonly double WhatDoesThisMean2 = 0.5 - Math.Sqrt(1.25); public static string\[\] **DesparatelyNeedsRefactoring**(int n) { if (n < 1) throw new ArgumentException("n must be greater than zero"); double d = Math.Pow(WhatDoesThisMean, n) - Math.Pow(WhatDoesThisMean2, n); var stringLength = (int) Math.Round(d / WhatDoesThisMean); return new string('\*', stringLength).Replace("\*", ".\*").Substring(1).Split('.'); }
Note that I would refactor the variable 'stringLength' out as well - I put that in there to try and figure out what was going on, before I gave up and Googled.
Before .NET 4.0, object Universe = NULL;
-
How about:
private static readonly double WhatDoesThisMean = 0.5 + Math.Sqrt(5); private static readonly double WhatDoesThisMean2 = 0.5 - Math.Sqrt(1.25); public static string\[\] **DesparatelyNeedsRefactoring**(int n) { if (n < 1) throw new ArgumentException("n must be greater than zero"); double d = Math.Pow(WhatDoesThisMean, n) - Math.Pow(WhatDoesThisMean2, n); var stringLength = (int) Math.Round(d / WhatDoesThisMean); return new string('\*', stringLength).Replace("\*", ".\*").Substring(1).Split('.'); }
Note that I would refactor the variable 'stringLength' out as well - I put that in there to try and figure out what was going on, before I gave up and Googled.
Before .NET 4.0, object Universe = NULL;
Hired Mind wrote:
I gave up and Googled
and? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hired Mind wrote:
I gave up and Googled
and? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
Got distracted by productive work, and then you gave a the answer in another post. Fibonacci sequence right?
Before .NET 4.0, object Universe = NULL;
-
Got distracted by productive work, and then you gave a the answer in another post. Fibonacci sequence right?
Before .NET 4.0, object Universe = NULL;
I must say I was rather pleased with myself at having worked out the correct answer before reading this post (and another) with the correct answer in. Of course if anybody actually implemented this in production code they would be told off. Reminds me of the pointer trickery fun we used to do in C "for performance reasons" :)