[EMAIL PROTECTED] schreef:
On Feb 6, 4:54 pm, John Machin [EMAIL PROTECTED] wrote:
Recursive? Bzzzt!
Might it not be better to halve the interval at each iteration instead
of calling a random number function? mid = (lo + hi) 1 looks
permitted and cheap to me. Also you don't run the risk of
Roel Schroeven schreef:
[EMAIL PROTECTED] schreef:
I had considered this, but to halve, you need to divide by 2. Using
random, while potentially increasing the number of iterations, removes
the dependency of language tricks and division.
It's possible to use Fibonacci numbers instead of
On Feb 1, 8:25 pm, Krypto [EMAIL PROTECTED] wrote:
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division by 7
Does anybody else notice that this breaks the spirit of the problem
(regardless of it's accuracy)? 'N-7' uses the subtraction
On Feb 6, 3:29 pm, [EMAIL PROTECTED] wrote:
On Feb 1, 8:25 pm, Krypto [EMAIL PROTECTED] wrote:
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division by 7
Does anybody else notice that this breaks the spirit of the problem
(regardless
On Feb 7, 2:29 am, [EMAIL PROTECTED] wrote:
On Feb 1, 8:25 pm, Krypto [EMAIL PROTECTED] wrote:
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division by 7
Does anybody else notice that this breaks the spirit of the problem
(regardless
On Feb 6, 4:54 pm, John Machin [EMAIL PROTECTED] wrote:
Recursive? Bzzzt!
I woudl be happy to hear your alternative, which doesn't depend on
language specific tricks. Thus far, all you have suggested is using an
alternative form of the division function, which I would consider to
be outside the
On Feb 7, 11:05 am, [EMAIL PROTECTED] wrote:
On Feb 6, 4:54 pm, John Machin [EMAIL PROTECTED] wrote:
Recursive? Bzzzt!
I woudl be happy to hear your alternative, which doesn't depend on
language specific tricks. Thus far, all you have suggested is using an
alternative form of the division
On Feb 1, 3:42 am, [EMAIL PROTECTED] wrote:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
It´s quiet simple. x == 8*(x/8) + x%8, so x == 7*(x/8) + (x/8 + x%8)
On 2007-02-01, Michael Yanowitz [EMAIL PROTECTED] wrote:
I think it is off by 1 in small numbers, off by a little more with large
numbers:
def div7 (N):
...return (N3) + ((N-7*(N3))3)
...
div7 (70)
9
div7 (77)
10
div7 (700)
98
div7 (7)
0
div7 (10)
1
div7 (14)
1
div7 (21)
2
On 31 Jan 2007 19:13:14 -0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Its not an homework. I appeared for EA sports interview last month. I
was asked this question and I got it wrong. I have already fidlled
around with the answer but I don't know the correct reasoning behind
it.
I think
On Feb 2, 11:03 pm, Bart Ogryczak [EMAIL PROTECTED] wrote:
On Feb 1, 3:42 am, [EMAIL PROTECTED] wrote:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
It´s
On Feb 3, 2:31 am, Jesse Chounard [EMAIL PROTECTED] wrote:
On 31 Jan 2007 19:13:14 -0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Its not an homework. I appeared for EA sports interview last month. I
was asked this question and I got it wrong. I have already fidlled
around with the
On Feb 1, 2:00 pm, Nicko [EMAIL PROTECTED] wrote:
precision and the answer that they were looking for was:
a = (b * 045L) 32
Note that the constant there is in octal.
045L? Shouldn´t it be 044?
Or more generally,
const = (1bitPrecision)/7
a = (b *
On Feb 2, 4:21 pm, Bart Ogryczak [EMAIL PROTECTED] wrote:
On Feb 1, 2:00 pm, Nicko [EMAIL PROTECTED] wrote:
precision and the answer that they were looking for was:
a = (b * 045L) 32
Note that the constant there is in octal.
045L? Shouldn´t it be 044?
Or
On Feb 1, 8:25 pm, Krypto [EMAIL PROTECTED] wrote:
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division by 7
No it doesn't. The above term tends towards N * (9/64), with some
significant rounding errors. 9/64 is a fairly poor (6 bit)
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
It may not be efficient, but the easiest solution (without using tricks
from a particular languages) is to increment a
In [EMAIL PROTECTED], Paul McGuire
wrote:
On Jan 31, 11:36 pm, Paddy [EMAIL PROTECTED] wrote:
On Feb 1, 2:42 am, [EMAIL PROTECTED] wrote:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I
This is maybe not so efficient :) but it implements integer division
by 7 for positive integers without - and /.
def div2(num):
return num 1
def div4(num):
return num 2
def div8(num):
return num 3
def mul2(num):
return num 1
def mul4(num):
return num 2
def mul7(num):
On Feb 1, 3:13 am, [EMAIL PROTECTED] wrote:
Its not an homework. I appeared for EA sports interview last month. I
was asked this question and I got it wrong. I have already fidlled
around with the answer but I don't know the correct reasoning behind
it.
In that case, observer that a/b == a *
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division by 7
--
http://mail.python.org/mailman/listinfo/python-list
Krypto [EMAIL PROTECTED] writes:
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division by 7
Well, not exactly:
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type help, copyright, credits or license for more information.
Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Krypto
Sent: Thursday, February 01, 2007 3:25 PM
To: python-list@python.org
Subject: Re: division by 7 efficiently ???
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
The above term always gives division
Michael I think it is off by 1 in small numbers, off by a little more
Michael with large numbers:
...
Sorta makes you think using the DIV instruction in the CPU is the way to
go. ;-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
In [EMAIL PROTECTED], Krypto wrote:
The correct answer as told to me by a person is
(N3) + ((N-7*(N3))3)
How could it be correct if it uses `-`? You ruled out `-` and `/` in your
first post.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
Erm, sounds like a homework problem... suggestion: think of how many
input bits you have,
[EMAIL PROTECTED] writes:
How to divide a number by 7 efficiently without using - or /
operator. We can use the bit operators. I was thinking about bit
shift operator but I don't know the correct answer.
I think you are asking for help on a homework assignment in violation
of collusion and
On Wed, 31 Jan 2007 18:42:54 -0800, krypto.wizard wrote:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
I'd be surprised if there was a trick for dividing by
Its not an homework. I appeared for EA sports interview last month. I
was asked this question and I got it wrong. I have already fidlled
around with the answer but I don't know the correct reasoning behind
it.
Thanks,
On Jan 31, 10:01 pm, Ben Finney [EMAIL PROTECTED]
wrote:
[EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Its not an homework. I appeared for EA sports interview last month. I
was asked this question and I got it wrong. I have already fidlled
around with the answer but I don't know the correct reasoning behind
it.
The answer to that question is that the fastest way to
On Feb 1, 2:42 am, [EMAIL PROTECTED] wrote:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
int.__div__(14,2)
7
Not a minus or division operator in sight ;-)
-
Paddy [EMAIL PROTECTED] writes:
On Feb 1, 2:42 am, [EMAIL PROTECTED] wrote:
How to divide a number by 7 efficiently without using - or / operator.
int.__div__(14,2)
7
Not a minus or division operator in sight ;-)
I salute you, sir. That's the perfect answer to the boneheaded
On Jan 31, 11:36 pm, Paddy [EMAIL PROTECTED] wrote:
On Feb 1, 2:42 am, [EMAIL PROTECTED] wrote:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
On Feb 1, 2:36 pm, John Nagle [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Its not an homework. I appeared for EA sports interview last month. I
was asked this question and I got it wrong. I have already fidlled
around with the answer but I don't know the correct reasoning behind
it.
34 matches
Mail list logo