Dave Angel davea.name> writes:
>
> > str_num = '1234567890'
> > n = 5
> >
> > strings = [str_num[i:i+5] for i in range(0, len(str_num)) if
> > len(str_num[i:i+5])==5]
>
> If you changed the range() size, you could eliminate the extra if test.
> After all, the only ones that'll be short are t
On 31/05/13 21:49, Nick Shemonsky wrote:
I did stumble upon using reduce ...but I didn't really
understand what it was doing
def product(intlist):
return reduce(operator.mul, intlist)
I explain reduce thusly in my Functional Programming topic:
-
The reduce function
On 05/31/2013 04:49 PM, Nick Shemonsky wrote:
Here's the final code... I kept the if statement that way if I throw
in a random series of numbers that isn't evenly divisible by 5, it'll
always work itself out. And this answered the 1000 digit problem
without issue.
str_num = '1234567890'
n =
Thanks for the responses. I am using python 2.7. I'm not new to
programming but might as well be... I last programmed heavily about a
decade ago in college. I was a MIS major so I did my fair share of
c++, sql, and php work but now I'm a windows sys admin so I haven't
used it much at all in a long
On 31/05/13 19:23, Nick Shemonsky wrote:
or maybe it'd be quicker to compare a to b through each iteration and
just keep the larger product rather than creating a giant list
You are probably right if it is a giant list.
str_num = '1234567890'
n = 5
strings = [str_num[i:i+5] for i in range(0
On 05/31/2013 02:23 PM, Nick Shemonsky wrote:
Hey there everybody. I'm new to python
Welcome. But are you new to programming, or just to Python in
particular? And which Python? I'd guess 2.7
and am attempting to teach
myself to code while brushing up on my math skills via the problems at
Hey there everybody. I'm new to python and am attempting to teach
myself to code while brushing up on my math skills via the problems at
projecteuler.net. My solutions thus far have been mostly brute force
and this is no exception but I'm having an issue with tackling some
iteration in the problem.