On 22 Jan., 23:56, [EMAIL PROTECTED] wrote:
> So anyone got an answer to which set of numbers gives the most targets
> from 100 onwards say (or from 0 onwards)? IsPythonupto the task?
It's (5, 8, 9, 50, 75, 100): 47561 targets altogether (including
negative ones), 25814 targets >= 100.
(BTW, 1226
On Jan 29, 9:02 am, [EMAIL PROTECTED] wrote:
Oops I sent too quickly...
> If you've found an efficient way to walk through the possible
> solutions only once, then
> - I expect that yours will be faster
> - and well done!
>
> I guess I should try to understand your code...
My code is quite nai
On Jan 29, 9:02 am, [EMAIL PROTECTED] wrote:
> If you've found an efficient way to walk through the possible
> solutions only once
As discussed earlier in this thread, the definition of 'only once' is
not as clear cut as one would first think (see Terry's thoughts on
this).
--
Arnaud
--
http://
On Jan 28, 10:11 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> My strategy was to walk through each solution "only once" (for a
> certain definition of "only once :), thus I was hoping not to need a
> hashtable.
Yes, that seems like it should be preferable (and indeed necessary for
a more gene
On Jan 28, 9:31 pm, [EMAIL PROTECTED] wrote:
> I also had a go at this problem for a bit of python practice, about 6
> months ago. I tried a few optimizations and my experience was that
> with only 6 seeds, a hash table was very effective. So effective, in
> fact, that it made all other optimizat
I see I don't have as many columns as I'd expected. Here's a
reformatted listing.
from time import time
from bisect import insort
from sys import argv
#-
# Hash table is a global variable
#-
I also had a go at this problem for a bit of python practice, about 6
months ago. I tried a few optimizations and my experience was that
with only 6 seeds, a hash table was very effective. So effective, in
fact, that it made all other optimizations more or less pointless.
Code below. Arguments
Right, I've cleaned up my efforts a bit:
* tried to improve the efficiency of the 'fold' technique that I
posted earlier.
* taken on Dan's email about equivalence of expressions
* created a problem random generator
* created a little function test to time and compare various things,
and a 'ran
My output looks better sorted. I.e., for s in sorted(solutions)...
Giving the easier to read/compare:
Target 234, numbers = (100, 9, 7, 6, 3, 1)
(6, 1, 'add', 100, 'mul', 7, 'sub', 9, 'add', 3, 'div')
(6, 9, 'sub', 7, 'mul', 1, 'sub', 100, 'add', 3, 'mul')
(7, 3, 'mul', 6,
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
>>
>> Ha - you can't have it both ways Arnaud! You don't want the computation to
>> go negative... doesn't that (and my "proof") have something to do with the
>> inverse nature of add and sub? :-)
Arnaud> I think I can have it both wa
On Jan 23, 8:40 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
> > "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
>
> Arnaud> FWIW, I have a clear idea of what the space of solutions is, and
> Arnaud> which solutions I consider to be equivalent. I'll explain it
> Arnaud> below. I'm not
Well I tried the NumPy array thing that I was talking about, to
parallelise the problem, and there were some difficulties with it.
Firstly, the pruning makes a really big difference to the speed, and
you don't get that if you're trying to parallelise the problem because
what is an equivalent calcul
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> FWIW, I have a clear idea of what the space of solutions is, and
Arnaud> which solutions I consider to be equivalent. I'll explain it
Arnaud> below. I'm not saying it's the right model, but it's the one
Arnaud> within which I
On Jan 23, 3:45 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
> Hi Arnaud and Dan
Hi Terry
> > "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
> >> What was wrong with the very fast(?) code you sent earlier?
>
> Arnaud> I thought it was a bit convoluted, wanted to try something I
> Arna
Hi Arnaud and Dan
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
>> What was wrong with the very fast(?) code you sent earlier?
Arnaud> I thought it was a bit convoluted, wanted to try something I
Arnaud> thought had more potential. I think the problem with the second
Arnaud> one
On Jan 22, 10:56 pm, [EMAIL PROTECTED] wrote:
> Arnaud and Terry,
>
> Great solutions both of you! Much nicer than mine. I particularly like
> Arnaud's latest one based on folding because it's so neat and
> conceptually simple. For me, it's the closest so far to my goal of the
> most elegant soluti
On Jan 22, 9:05 am, Terry Jones <[EMAIL PROTECTED]> wrote:
> Hi Arnaud
>
> > I've tried a completely different approach, that I imagine as 'folding'. I
> > thought it would improve performance over my previous effort but extremely
> > limited and crude benchmarking seems to indicate disappointingl
Arnaud and Terry,
Great solutions both of you! Much nicer than mine. I particularly like
Arnaud's latest one based on folding because it's so neat and
conceptually simple. For me, it's the closest so far to my goal of the
most elegant solution.
So anyone got an answer to which set of numbers give
Hi Arnaud
> I've tried a completely different approach, that I imagine as 'folding'. I
> thought it would improve performance over my previous effort but extremely
> limited and crude benchmarking seems to indicate disappointingly comparable
> performance...
I wrote a stack-based version yesterd
On Jan 20, 5:41 pm, [EMAIL PROTECTED] wrote:
> Ever since I learnt to program I've always loved writing solvers for
> the Countdown numbers game problem in different languages, and so now
> I'm wondering what the most elegant solution in Python is.
I've tried a completely different approach, that
On Jan 21, 9:01 am, [EMAIL PROTECTED] wrote:
> Arnaud: I haven't had time to play with your solution yet - how quick
> does it run?
Ok I've done some quick timings, it's faster than I remembered it:
numbers = [2, 4, 5, 8, 25]
target = 758
Average time to find
(1) best solution (in terms of leng
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> Sorry I gave an incorrect example to illustrate my question last
Arnaud> night (I blame this on baby-induced sleep deprivation ;), so I'll
Arnaud> have another go:
Arnaud> Say I have 2, 3, 4, 100 and I want to make 406. AFAIC
> "cokofreedom" == cokofreedom <[EMAIL PROTECTED]> writes:
cokofreedom> Terry, your technique is efficient and pretty readable! All
cokofreedom> that could be added now is a way to output the data in a more
cokofreedom> user-friendly print.
Yes, and a fix for the bug Arnaud just pointed out
On Jan 21, 9:12 am, Terry Jones <[EMAIL PROTECTED]> wrote:
[...]
> Hi Arnaud.
Hi Terry
[...]
> WRT to the missing solution, note that my code only allowed multiplication
> by 1 if it was the last thing done. That was because you can multiply by 1
> at any time, and I didn't want to see those triv
On Jan 21, 11:29 am, Terry Jones <[EMAIL PROTECTED]> wrote:
> > "dg" == dg google groups <[EMAIL PROTECTED]> writes:
>
> dg> It's great how many different sorts of solutions (or almost solutions)
> dg> this puzzle has generated. Speedwise, for reference my solution posted
> dg> above takes abou
On Jan 21, 9:01 am, [EMAIL PROTECTED] wrote:
> Hi all,
>
> It's great how many different sorts of solutions (or almost solutions)
> this puzzle has generated. Speedwise, for reference my solution posted
> above takes about 40 seconds on my 1.8GHz laptop, and the less elegant
> version (on my webpag
> "dg" == dg google groups <[EMAIL PROTECTED]> writes:
dg> It's great how many different sorts of solutions (or almost solutions)
dg> this puzzle has generated. Speedwise, for reference my solution posted
dg> above takes about 40 seconds on my 1.8GHz laptop, and the less elegant
dg> version (o
On Mon, 21 Jan 2008 01:15:50 -0800, dg.google.groups wrote:
> Decided I may as well post my other solution while I'm at it. The neat
> trick here is redefining the add, mul, etc. functions so that they raise
> exceptions for example if x>y then add(x,y) raises an exception which is
> handled by th
Decided I may as well post my other solution while I'm at it. The neat
trick here is redefining the add, mul, etc. functions so that they
raise exceptions for example if x>y then add(x,y) raises an exception
which is handled by the search algorithm to mean don't continue that
computation - this sto
> "Paul" == Paul Rubin <"http://phr.cx"@NOSPAM.invalid> writes:
Hi Paul
Paul> Here's my latest, which I think is exhaustive, but it is very slow.
Paul> It prints a progress message now and then just to give the user some
Paul> sign of life. It should print a total of 256-8 = 248 of those
Pau
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> In countdown you are not required to use all numbers to reach the
Arnaud> target. This means you are missing solutions, e.g. (1, 3, 6,
Arnaud> 'mul', 'add', 7 , 'add', 9, 'mul')
Hi Arnaud.
Thanks, I didn't know that. The fix
Hi all,
It's great how many different sorts of solutions (or almost solutions)
this puzzle has generated. Speedwise, for reference my solution posted
above takes about 40 seconds on my 1.8GHz laptop, and the less elegant
version (on my webpage linked to in the original post) takes about 15
seconds
Arnaud Delobelle <[EMAIL PROTECTED]> writes:
> Update: 2, 4, 5, 8, 9, 25 can reach any target between 100 and 999.
Are you sure? What expression do you get for target = 758?
--
http://mail.python.org/mailman/listinfo/python-list
Arnaud Delobelle <[EMAIL PROTECTED]> writes:
> After a quick glance at your code it seems to me that you can only
> have solutions of the type:
> (num, num, op, num, op, num, op, num, op, num, op)
> this omits many possible solutions (see the one above).
Here's my latest, which I think is
On Jan 21, 3:19 am, Terry Jones <[EMAIL PROTECTED]> wrote:
> Here's a solution that doesn't use any copying of lists in for recursion.
> It also eliminates a bunch of trivially equivalent solutions. The countdown
> function is 37 lines of non-comment code. Sample (RPN) output below.
>
> Terry
[sn
Terry Jones <[EMAIL PROTECTED]> writes:
> Here's a solution that doesn't use any copying of lists in for recursion.
> It also eliminates a bunch of trivially equivalent solutions. The countdown
> function is 37 lines of non-comment code. Sample (RPN) output below.
Nice, I realized after I posted
Here's a solution that doesn't use any copying of lists in for recursion.
It also eliminates a bunch of trivially equivalent solutions. The countdown
function is 37 lines of non-comment code. Sample (RPN) output below.
Terry
from operator import *
def countdown(target, nums, numsAvail, value,
On Jan 21, 1:07 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Jan 20, 5:41 pm, [EMAIL PROTECTED] wrote:
>
> > Ever since I learnt to program I've always loved writing solvers for
> > the Countdown numbers game problem in different languages
>
> Ok so here's a challenge I just thought of:
>
>
On Jan 20, 5:41 pm, [EMAIL PROTECTED] wrote:
> Ever since I learnt to program I've always loved writing solvers for
> the Countdown numbers game problem in different languages
Ok so here's a challenge I just thought of:
What is (or are) the set of 6 starting numbers which are such that the
smalle
[EMAIL PROTECTED] writes:
> Unfortunately I realise I stated the problem imprecisely. You're only
> allowed to use each number once (otherwise there's a trivial solution
> for every problem, i.e. x/x + x/x + x/x + ... + x/x repeated y times
> for target y given any source number x). Trying your pro
[EMAIL PROTECTED] wrote:
> Ever since I learnt to program I've always loved writing solvers for
> the Countdown numbers game problem in different languages, and so now
> I'm wondering what the most elegant solution in Python is.
>
> If you don't know the game, it's simple: you're given six randoml
On Jan 20, 5:41 pm, [EMAIL PROTECTED] wrote:
> Ever since I learnt to program I've always loved writing solvers for
> the Countdown numbers game problem in different languages, and so now
> I'm wondering what the most elegant solution in Python is.
>
> If you don't know the game, it's simple: you'r
[EMAIL PROTECTED] writes:
> Unfortunately I realise I stated the problem imprecisely. You're only
> allowed to use each number once (otherwise there's a trivial solution
> for every problem, i.e. x/x + x/x + x/x + ... + x/x repeated y times
> for target y given any source number x). Trying your pro
Hi Marek,
That's a really nice solution (and ultrafast).
Unfortunately I realise I stated the problem imprecisely. You're only
allowed to use each number once (otherwise there's a trivial solution
for every problem, i.e. x/x + x/x + x/x + ... + x/x repeated y times
for target y given any source n
En Sun, 20 Jan 2008 18:06:57 -0200, <[EMAIL PROTECTED]> escribi�:
> Nice challenge! I came up with something like this:
A nice solution too!
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list
Nice challenge! I came up with something like this:
def find_repr(target, numbers):
org_reprs = dict((number, str(number)) for number in numbers)
curr_reprs = org_reprs
while target not in curr_reprs:
old_reprs, curr_reprs = curr_reprs, {}
fo
Ever since I learnt to program I've always loved writing solvers for
the Countdown numbers game problem in different languages, and so now
I'm wondering what the most elegant solution in Python is.
If you don't know the game, it's simple: you're given six randomly
chosen positive integers, and a t
47 matches
Mail list logo