Skip to main content
Code Review

Timeline for Randomly generate a list with predetermined mean

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
May 23, 2017 at 12:40 history edited Community Bot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Dec 15, 2016 at 19:17 history edited Peilonrayz CC BY-SA 3.0
Pretty much re-write the answer.
Dec 15, 2016 at 16:07 vote accept user2738815
Dec 15, 2016 at 16:07
Dec 15, 2016 at 15:33 comment added user2738815 Sincerely grateful for the time you are putting into this. Yes, since I have been teaching logic for years, I am familiar with that wider sense of "algorithm" according to which even well-written pizza recipes are one :) However, I do not think they will be taught in a CS course called "Algorithms".
Dec 15, 2016 at 10:06 comment added Peilonrayz @user2738815 Yeah, I messed up. I was transforming the array whilst modifying it, and so if you randomly got stop at the end you'd infinitely loop. It should now be fixed, this was also the cause of the odd means. If you look at a definition of algorithm, "an algorithm is a self-contained step-by-step set of operations to be performed" - Wikipedia, it's what your code is.
Dec 15, 2016 at 10:03 history edited Peilonrayz CC BY-SA 3.0
Fix code, unshifting whilst changing is _bad_.
Dec 15, 2016 at 4:08 comment added user2738815 Thanks, I am studying/testing your answer, but am hitting a snag. When I make the call numbers_with_mean(x, 50, 1, 100, 1) using a loop with x ranging from 30 to 70, output time for each step takes around .0002 seconds until a certain mean -- then the program gets stuck in run-time (no error message, stuck at different mean each time). Also, where did you get the idea that my code was an "algorithm" :) I am just a beginner who is asking for help.
Dec 14, 2016 at 16:56 history answered Peilonrayz CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /