A company builds towers with bricks. The company can build two types of towers: impressive and regular. It takes the company 1024 bricks to build impressive towers and 256 bricks to build regular towers. The company makes the most gain by building impressive towers: CDN$10000 each. Regular towers produce less gain but still some: a regular tower provides the company CDN$ 2000 gain. On the other hand, the company loses CDN$ 20 per brick not used. Thus, the company will attempt to make as many impressive towers as possible, and then as many regular towers as possible.

This function receives as input parameter a number of bricks and it should return a string with the following information: first, the number of impressive towers to build, followed by two dots ("..") followed by the number of regular towers to build, followed again by two dots, followed by the number of unused bricks, followed by two dots and finally the money the company makes, considering the gains (becuase of the towers) minus the losses (becasue of the unused bricks).

For example,

bricksAndTowers(1027) should return '1..0..3..9940', because with 1027 bricks one impressive tower can be built (the first 1 in the string), no regular towers can be built (0) and there are 3 unused bricks. The company makes CDN$ 9940, that is, CDN$10000 because of the impressive tower minus CDN$ 60 (CDN$20 per each of the 3 unused bricks).

Notice that the company may have a net loss, when there are not enough bricks to build any tower.

We are happy to help with homework, but you must make a reasonable effort before we do anything for you. Ask a question, don't just say what your prompt is. Post your best code attempt, even if it doesn't work. Post the traceback associated with your code, if it has one, and not just the error message.

ltcy wrote:A company builds towers with bricks. The company can build two types of towers: impressive and regular. It takes the company 1024 bricks to build impressive towers and 256 bricks to build regular towers. The company makes the most gain by building impressive towers: CDN$10000 each. Regular towers produce less gain but still some: a regular tower provides the company CDN$ 2000 gain. On the other hand, the company loses CDN$ 20 per brick not used. Thus, the company will attempt to make as many impressive towers as possible, and then as many regular towers as possible.

This function receives as input parameter a number of bricks and it should return a string with the following information: first, the number of impressive towers to build, followed by two dots ("..") followed by the number of regular towers to build, followed again by two dots, followed by the number of unused bricks, followed by two dots and finally the money the company makes, considering the gains (becuase of the towers) minus the losses (becasue of the unused bricks).

For example,

bricksAndTowers(1027) should return '1..0..3..9940', because with 1027 bricks one impressive tower can be built (the first 1 in the string), no regular towers can be built (0) and there are 3 unused bricks. The company makes CDN$ 9940, that is, CDN$10000 because of the impressive tower minus CDN$ 60 (CDN$20 per each of the 3 unused bricks).

Notice that the company may have a net loss, when there are not enough bricks to build any tower.

micseydel wrote:We are happy to help with homework, but you must make a reasonable effort before we do anything for you. Ask a question, don't just say what your prompt is. Post your best code attempt, even if it doesn't work. Post the traceback associated with your code, if it has one, and not just the error message.

Just for starters, your indentation is wrong and you are using return when not using a function or method.

Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

Yeah, that second bit of code looks like it would work if you put it in a function definition. At least it would return the right profit or loss for the company. To get the string output requested by the problem, there's lots of options. The easiest is just string addition:

Due to the reasons discussed here we will be moving to python-forum.io on October 1st, 2016.This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.