[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

A consignment shop accepts a product for sale and sets an initial

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 3

File: 7i1lvije90by.png (53KB, 542x497px) Image search: [Google]
7i1lvije90by.png
53KB, 542x497px
A consignment shop accepts a product for sale and sets an initial price. Each
month that the item doesn’t sell, the price is reduced by 20 percent. When the item
sells, the item’s owner receives 60 percent of the sale price, and the shop gets
40 percent. Draw a flowchart or write pseudocode to represent the logic of a
program that allows the user to enter an original product price. The output is the
sale price, the owner’s cut, and the shop’s cut each month for the first three
months the item is on sale.
start
input initialprice
set firstmonthprice = initialprice * 0.80
set secondmonthprice = firstmonthprice * 0.80
set thirdmonthprice = secondmonthprice * 0.80
set ownerfirstmonthcut = firstmonthprice * 0.60
set shopfirstmonthcut = firstmonthprice * 0.40
set ownersecondmonthcut = secondmonthprice * 0.60
set shopsecondmonthcut = secondmonthprice * 0.40
set ownerthirdmonthcut = thirdmonthprice * 0.60
set shopthirdmonthcut = thirdmonthprice * 0.40
output firstmonthprice
output ownerfirstmonthcut
output shopfirstmonthcut
output secondmonthprice
output ownersecondmonthcut
output shopsecondmonthcut
output thirdmonthprice
output ownerthirdmonthcut
output shopthirdmonthcut
end
>>
>>62248143
What's wrong with the method on the picture?
Comparing A and B, than AB and c would be a better solution?
>>
>>62249257
I must be an idiot too, I cannot find the issue with op pic code.
>>
File: 1460115589005.png (30KB, 657x527px) Image search: [Google]
1460115589005.png
30KB, 657x527px
>fizzbuzz the primes under 100
>>
Please don't bully because I'm a brainlet but what would be a the most optimal solution?

I would try to dumb all elements into a single array and then check for each element if a duplicate exist in that big array but that doesn't seem right either. But it would atleast reduce the O to N!.
>>
>>62249369
that would be bad, because what if one array had for example three 7s, but the other none
>>
>>62249396
True, then I can't think of any other solution.
>>
>>62249257
>>62249342
>>62249369
>>62249443

it's because it is a perfectly acceptable solution

the pic makes the point that anybody who sees code in this meme format, they assume that it is shit quality, and the average /g/ user has the confidence of a wet noodle so they assume they are brainlets because they can't think of anything better
>>
File: ultimatesadness.jpg (24KB, 600x522px) Image search: [Google]
ultimatesadness.jpg
24KB, 600x522px
>>62249470
Sorry.
>>
>>62249470
It is acceptable but it still is retarded. Instead of doing this stupid control in O(n3), you could do it in O(n2) if you compared A to B, kept a list of the numbers that are in both then compared the intersection between A and B with C. And there's probably more ways to do this even faster.
>>
>>62249470
>it's because it is a perfectly acceptable solution

Yeah, lets ignore the fact its O(n^3) time. If you used a btree/hash table you can cut it down to nlogn
>>
>>62249369
This would work if you sorted each group, removed the duplicates, merged them, sorted again and looked for three equal numbers next to each other. It would bring all down to O(nlogn) but as >>62249633 said you'd be probably better off with a hash table at this point.
>>
>>62248143
OP' method is bad because it O(n^3) when it could be faster. A quick, naive improvement would put it at O(n^2). By using the proper data structure for the set, one that keeps elements sorted, you could make it O(n).
>>
the method isn't generalized either.

unless your lang sucks and doesn't have variadics.
>>
>62249257
>62249342
It's a somewhat naive solution, in that there are better alternatives that should be evident to those who have studied algorithms; but it's by no means bad code. Certainly not meme-tier.
Thread posts: 15
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.