Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: Program Help Pin
OriginalGriff11-Aug-18 20:08
mveOriginalGriff11-Aug-18 20:08 
GeneralRe: Program Help Pin
AnotherKen18-Aug-18 9:04
professionalAnotherKen18-Aug-18 9:04 
GeneralRe: Program Help Pin
Mycroft Holmes18-Aug-18 13:30
professionalMycroft Holmes18-Aug-18 13:30 
GeneralRe: Program Help Pin
AnotherKen18-Aug-18 19:18
professionalAnotherKen18-Aug-18 19:18 
AnswerRe: Program Help Pin
Richard Andrew x6412-Aug-18 3:32
professionalRichard Andrew x6412-Aug-18 3:32 
QuestionSplit a number into multiple number in a specific way Pin
Mou_kol10-Aug-18 11:14
Mou_kol10-Aug-18 11:14 
AnswerRe: Number distribution in a specific way Pin
Mycroft Holmes10-Aug-18 13:34
professionalMycroft Holmes10-Aug-18 13:34 
AnswerRe: Number distribution in a specific way Pin
Luc Pattyn11-Aug-18 6:22
sitebuilderLuc Pattyn11-Aug-18 6:22 
Hi,

I'm confused, your code is implementing something that is harder than what your requirements stipulate, assuming I understood them correctly, as in: generate N positive integers totalling SUM, where the first N-1 numbers are identical and maximal.

If so, this would be the "algorithm" for N>0 and SUM>=0:
for(int i=0; i<N-1; i++) yield return SUM/N;    // first N-1 numbers
yield return SUM-SUM/N*(N-1);                   // making sure total equals SUM


As this is an integer problem, no doubles are involved; for positive numbers integer divide returns the (floored) quotient.

Further comment: I see no need to order the list as you do, and if you really want a List<int> then why do you use IEnumerable.ToList, your method could create a List<int> straight away...

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

QuestionGet file metada Pin
Member 1193763910-Aug-18 0:04
Member 1193763910-Aug-18 0:04 
AnswerRe: Get file metada Pin
Richard MacCutchan10-Aug-18 0:22
mveRichard MacCutchan10-Aug-18 0:22 
QuestionRDP connections in tabs Pin
Member 114416229-Aug-18 19:41
Member 114416229-Aug-18 19:41 
AnswerRe: RDP connections in tabs Pin
Mycroft Holmes9-Aug-18 20:20
professionalMycroft Holmes9-Aug-18 20:20 
GeneralRe: RDP connections in tabs Pin
Member 1144162212-Aug-18 23:54
Member 1144162212-Aug-18 23:54 
GeneralRe: RDP connections in tabs Pin
Pete O'Hanlon13-Aug-18 0:27
mvePete O'Hanlon13-Aug-18 0:27 
GeneralRe: RDP connections in tabs Pin
Member 1144162213-Aug-18 1:17
Member 1144162213-Aug-18 1:17 
GeneralRe: RDP connections in tabs Pin
Pete O'Hanlon13-Aug-18 1:23
mvePete O'Hanlon13-Aug-18 1:23 
GeneralRe: RDP connections in tabs Pin
Mycroft Holmes13-Aug-18 2:16
professionalMycroft Holmes13-Aug-18 2:16 
GeneralRe: RDP connections in tabs Pin
Member 1144162213-Aug-18 3:10
Member 1144162213-Aug-18 3:10 
GeneralRe: RDP connections in tabs Pin
Mycroft Holmes13-Aug-18 13:28
professionalMycroft Holmes13-Aug-18 13:28 
QuestionClasses In Threads - Pause One Until Another Finished Pin
Kevin Marois8-Aug-18 6:43
professionalKevin Marois8-Aug-18 6:43 
AnswerRe: Classes In Threads - Pause One Until Another Finished Pin
Richard Deeming8-Aug-18 8:05
mveRichard Deeming8-Aug-18 8:05 
AnswerRe: Classes In Threads - Pause One Until Another Finished Pin
OriginalGriff8-Aug-18 8:09
mveOriginalGriff8-Aug-18 8:09 
GeneralRe: Classes In Threads - Pause One Until Another Finished Pin
Kevin Marois8-Aug-18 8:22
professionalKevin Marois8-Aug-18 8:22 
GeneralRe: Classes In Threads - Pause One Until Another Finished Pin
OriginalGriff8-Aug-18 22:08
mveOriginalGriff8-Aug-18 22:08 
GeneralRe: Classes In Threads - Pause One Until Another Finished Pin
Richard Deeming9-Aug-18 0:48
mveRichard Deeming9-Aug-18 0:48 

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.