| View previous topic :: View next topic |
| Author |
Message |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Fri Jan 18, 2008 2:53 am Post subject: Are you a economical programer? |
|
|
Try this question:
In every cab only 6 people can get in.
Calculate how much cabs you need for X people only with +,-,* and /.
(no if,case/switch,while,for or somthing like that).
You can do it in in one line.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25872 Location: The netherlands
|
Posted: Fri Jan 18, 2008 2:56 am Post subject: |
|
|
y=x%6>0 ? (x/6)+1 : x/6;
ok, you didn't say % was allowed, but I like it better this way
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Fri Jan 18, 2008 2:57 am Post subject: |
|
|
cabs = x / 6
x being amount of people
hm?
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Fri Jan 18, 2008 2:59 am Post subject: |
|
|
@DarkByte: Very nice, there is an easyer way
@stealthy17:Wrong, for 7 people you need 2 cabs not one
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Fri Jan 18, 2008 3:31 am Post subject: |
|
|
Well in theory it's true what i wrote.
But in reality you can't drive 0,1666666666666666666666666666667 cab lol.
Guess it could be rounded up if that's allowed? =o
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Fri Jan 18, 2008 7:26 am Post subject: |
|
|
| stealthy17 wrote: | Well in theory it's true what i wrote.
But in reality you can't drive 0,1666666666666666666666666666667 cab lol.
Guess it could be rounded up if that's allowed? =o |
Sorry but it's wrong.
The right and best answer is: | Code: | | cabs = (NumOfPpl + 5)\6 |
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Fri Jan 18, 2008 7:28 am Post subject: |
|
|
Matter of opinion i guess.
Also theory and practicum are 2 differences.
I was right in a theoretical way you are in practicum.
Oh well...
|
|
| Back to top |
|
 |
Trow Grandmaster Cheater
Reputation: 2
Joined: 17 Aug 2006 Posts: 957
|
Posted: Fri Jan 18, 2008 8:42 am Post subject: |
|
|
explain your +5 plox
reason to ask you to explain: you didn't say \ is allowed; you said /. and you know they are different. anyways what's data type of cabs?
_________________
Get kidnapped often. |
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Fri Jan 18, 2008 9:06 am Post subject: |
|
|
+5 is used for the minimal argument, which is, in this case 1:
(1+5)/6=1|...|(6+5)/6=1
The point is the non-fractured calculation(integers only)...
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Fri Jan 18, 2008 9:33 am Post subject: |
|
|
| *zips*
|
|
| Back to top |
|
 |
|