pseudocode

Sales area partitioning between salesreps

爷,独闯天下 提交于 2019-12-11 19:38:44
问题 I have a list of zip codes from customers that need to be visited by a salesrep within a specific timeframe. I can translate the zipcodes to a matrix of distances between each zipcode if required. Assuming every customer needs to be visited within the same fixed time span. How can I cluster/assign customers to salesreps so that every customer is visited in within the timeframe and the total number of salesreps is minimised? Can this be restated as a 'standard' problem? 来源: https:/

given a series of stock prices in an array. Pick when to buy and when to sell to gain max profit

廉价感情. 提交于 2019-12-11 18:02:57
问题 given a series of stock prices in an array. Pick when to buy and when to sell to gain max profit. from one website i got something like this-ef maxprofit(prices): buydate, selldate = 0, 0 maxprof = 0 minprice = prices[0] mindate = 0 for d, p in enumerate(prices[1:]): if p < minprice: minprice = p mindate = d + 1 continue prof = p - minprice if prof > maxprof: maxprof = prof buydate, selldate = mindate, d + 1 return (buydate, selldate), maxprof but i think..we should consider negative prices

Pseudocode for getting order based on Dependency

爱⌒轻易说出口 提交于 2019-12-11 16:04:02
问题 Ok, my situation is this I have a list of items and I need to get the order of these items based on the references they have. For example lets say we have these items: A,B,C,D,E,F C and D have no dependencies so their order can be 0. B is the one that has the most with C, D and A. A has C and F has A and B C D | \ / A / / | / | B \ | F In this case C,D = 0 A = 1 B= 2 F = 3 I have been looking through the internet and it seems I am not using the correct scientific term for this. Most probably

Simple Pseudocode Code Question

心不动则不痛 提交于 2019-12-11 15:48:35
问题 I'm a little new to pseudocode. I understand what the code is saying, but having a hard time putting the pieces together. How should I be thinking to understand what this code is doing: Suppose that a1, a2, . . . , ak is an array of k numbers. What does the following code fragment do? Briefly explain why. Assume that all the indented lines belong inside the loop. 1 for p := 1 to ⌊k/2⌋ 2 t := ap 3 ap := ak−p+1 4 ak−p+1 := t 回答1: Ookay, 1 for p := 1 to ⌊k/2⌋ means, we're going up to the half of

Is my pseudo code for changing time format correct? [duplicate]

拈花ヽ惹草 提交于 2019-12-11 14:55:29
问题 This question already has answers here : Convert 12-hour date/time to 24-hour date/time (8 answers) Closed 5 years ago . I need to create a pseudo code that will prompt for time in 24 hours format, convert it to 12-hour format and also whether it is AM or PM. It will have to repeat until sentinel time of 9999 is entered. Below is what I had come out with, is it correct? Prompt for time Get time Enter this loop: DOWHILE (time != 9999) IF (time < 0000 OR time > 2400 OR (time%100 >=60)) Display

Need help converting a Multi-Cell Excel formula to basic pseudo code

北城以北 提交于 2019-12-11 14:26:33
问题 I don't think the whole spreadsheet is relevant here (Hope I am not wrong) but essentially I am working with some financial figures and need to work out a "Cumulative Cost". The spreadsheet is correct, but I don't understand the maths of the formula, so I hope somebody can break it down into BODMAS or pseudo code or something (or even Java which it will ultimately be.) {=(PRODUCT($D$4:D7/100+1)-1)*100} {=(PRODUCT($D$4:D8/100+1)-1)*100} {=(PRODUCT($D$4:D9/100+1)-1)*100} etc.. I think I only

Binary string to Decimal integer converter

孤人 提交于 2019-12-11 12:37:30
问题 I am trying to write a program that converts a 4-bit string representation of binary into a decimal (base 10) integer. This is what I got so far, but after I type In the 4-bit binary (e.g. 1101) It just comes out with: '>>>'. Here is the flow diagram I am following: Here is my code: def binaryToDenary(): Answer = 0 Column = 8 Bit = int(input("Enter bit value: ")) if Column >1: Answer = Answer + (Column * Bit) Column = Column/2 elif Column <1: print("The decimal value is: " + Answer)

Modular exponentiation implementation in Python 3

£可爱£侵袭症+ 提交于 2019-12-11 07:54:25
问题 Basically this is a homework question. I'm supposed to implement these two pseudo-code algorithms in Python3. I'm doing something wrong and I can't figure out what (it seems like this should be simple so I'm not sure what/where I botched this. It could be my algorithm or my lack of experience with Python. I'm not sure which.). Please tell me what I did wrong, don't post any code. If I get code for an answer I'll get pegged for plagiarism (which I very much do not want). The first algorithm

Angle between two lines beginning at one side of the line

一曲冷凌霜 提交于 2019-12-11 07:07:23
问题 I have two lines specified by two points with x and y coordinate each. The first point (where the lines begin) is equal meaning that I have 3 points A, B and C where one line is from A to B and the other one from A to C. I would then want to calculate the angle between the two lines starting at the right side of the first line . The result needn't be accurate I actually only need to know if this angle is greater or less than 180° (π rad). Thanks for any help - you needn't write any code,

Understanding simple simulation and rendering loop

你。 提交于 2019-12-11 06:24:29
问题 This is an example (pseudo code) of how you could simulate and render a video game. //simulate 20ms into the future const long delta = 20; long simulationTime = 0; while(true) { while(simulationTime < GetMilliSeconds()) //GetMilliSeconds = Wall Clock Time { //the frame we simulated is still in the past input = GetUserlnput(); UpdateSimulation(delta, input); //we are trying to catch up and eventually pass the wall clock time simulationTime += delta; } //since my current simulation is in the