Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: Coding Challenge Pin
Mycroft Holmes26-Aug-17 15:33
professionalMycroft Holmes26-Aug-17 15:33 
GeneralRe: Coding Challenge Pin
PIEBALDconsult26-Aug-17 16:14
mvePIEBALDconsult26-Aug-17 16:14 
QuestionRe: Coding Challenge Pin
PIEBALDconsult26-Aug-17 16:56
mvePIEBALDconsult26-Aug-17 16:56 
AnswerRe: Coding Challenge Pin
Mycroft Holmes26-Aug-17 22:20
professionalMycroft Holmes26-Aug-17 22:20 
AnswerRe: Coding Challenge Pin
BillWoodruff26-Aug-17 19:44
professionalBillWoodruff26-Aug-17 19:44 
AnswerRe: Coding Challenge Pin
Peter_in_278027-Aug-17 1:41
professionalPeter_in_278027-Aug-17 1:41 
AnswerRe: Coding Challenge Pin
Richard Deeming29-Aug-17 2:28
mveRichard Deeming29-Aug-17 2:28 
GeneralRe: Coding Challenge Pin
Mycroft Holmes4-Sep-17 21:06
professionalMycroft Holmes4-Sep-17 21:06 
Your name is getting into my code base. I like to link back to these answers as the make excellent doco Big Grin | :-D The final function...
C#
/// <summary>
/// <a href="https://www.codeproject.com/Messages/5430072/Re-Coding-Challenge.aspx">https://www.codeproject.com/Messages/5430072/Re-Coding-Challenge.aspx</a>
/// See Richard Deemings response
/// </summary>
/// <param name="lValues">list of decimals to get the average growth from</param>
/// <returns>list of 2 growth values basedon the last value and the average growth</returns>
private List<decimal> CalcAverageGrowth(List<decimal> lValues)
{
  // lValues = new List<decimal>() { 100, 120, 118, 126, 102 };
  List<decimal> lResult = new List<decimal>();
  decimal average = lValues.Skip(1).Take(lValues.Count - 1)
.Zip(lValues, (second, first) => (second - first) / second)
.Average();
  lResult.Add(lValues.Last() + (lValues.Last() * average));
  lResult.Add(lResult.Last() + (lResult.Last() * average));
  return lResult;
}
Never underestimate the power of human stupidity
RAH

SuggestionRe: Coding Challenge Pin
Richard Deeming5-Sep-17 1:55
mveRichard Deeming5-Sep-17 1:55 
GeneralRe: Coding Challenge Pin
Mycroft Holmes4-Sep-17 22:24
professionalMycroft Holmes4-Sep-17 22:24 
GeneralRe: Coding Challenge Pin
Pete O'Hanlon4-Sep-17 23:24
mvePete O'Hanlon4-Sep-17 23:24 
GeneralRe: Coding Challenge Pin
Richard Deeming5-Sep-17 2:04
mveRichard Deeming5-Sep-17 2:04 
AnswerRe: Coding Challenge Pin
Pete O'Hanlon29-Aug-17 3:53
mvePete O'Hanlon29-Aug-17 3:53 
Questionc++ const in c# (I assume, once again) Pin
User 1106097925-Aug-17 8:04
User 1106097925-Aug-17 8:04 
AnswerRe: c++ const in c# (I assume, once again) Pin
OriginalGriff25-Aug-17 8:37
mveOriginalGriff25-Aug-17 8:37 
GeneralRe: c++ const in c# (I assume, once again) Pin
User 1106097925-Aug-17 8:43
User 1106097925-Aug-17 8:43 
GeneralRe: c++ const in c# (I assume, once again) Pin
User 1106097925-Aug-17 9:01
User 1106097925-Aug-17 9:01 
GeneralRe: c++ const in c# (I assume, once again) Pin
harold aptroot25-Aug-17 8:41
harold aptroot25-Aug-17 8:41 
GeneralRe: c++ const in c# (I assume, once again) Pin
User 1106097925-Aug-17 8:47
User 1106097925-Aug-17 8:47 
AnswerRe: c++ const in c# (I assume, once again) Pin
jschell25-Aug-17 9:40
jschell25-Aug-17 9:40 
GeneralRe: c++ const in c# (I assume, once again) Pin
User 1106097925-Aug-17 9:50
User 1106097925-Aug-17 9:50 
AnswerRe: c++ const in c# (I assume, once again) Pin
Pete O'Hanlon25-Aug-17 12:19
mvePete O'Hanlon25-Aug-17 12:19 
GeneralRe: c++ const in c# (I assume, once again) Pin
User 1106097925-Aug-17 12:47
User 1106097925-Aug-17 12:47 
AnswerRe: c++ const in c# (I assume, once again) Pin
Gerry Schmitz26-Aug-17 8:54
mveGerry Schmitz26-Aug-17 8:54 
AnswerRe: c++ const in c# (I assume, once again) Pin
Bernhard Hiller28-Aug-17 3:39
Bernhard Hiller28-Aug-17 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.