I have read all comments and im a little bit confused.
About which script are we talkimng about. I have seen a lot.
Roelof
From: keithw...@gmail.com
Date: Sun, 12 Jan 2014 16:43:40 -0500
CC: tutor@python.org
Subject: Re: [Tutor] another better way to do this ?
On Sun, Jan 12, 2014 at 2
On Mon, Jan 13, 2014 at 1:14 AM, Roelof Wobben rwob...@hotmail.com wrote:
I have read all comments and im a little bit confused.
About which script are we talkimng about. I have seen a lot.
I am talking about the script/approach I posted. Others have posted
other scripts. Hopefully you have
Peter Otten wrote:
Emile van Sebille wrote:
On 01/12/2014 12:21 PM, Peter Otten wrote:
test(axbxc, abc)
True
test(abbxc, abc)
False
Is the second result desired?
No -- the second should match -- you found a test case I didn't...
def test(a,b):
for ii in a:
if ii not in
Yikes, Peter, that's scary. Wow.
On Mon, Jan 13, 2014 at 1:22 PM, Peter Otten __pete...@web.de wrote:
Peter Otten wrote:
Emile van Sebille wrote:
On 01/12/2014 12:21 PM, Peter Otten wrote:
test(axbxc, abc)
True
test(abbxc, abc)
False
Is the second result desired?
No -- the second
From: keithw...@gmail.com
Date: Mon, 13 Jan 2014 12:56:45 -0500
Subject: Re: [Tutor] another better way to do this ?
To: rwob...@hotmail.com
CC: tutor@python.org
On Mon, Jan 13, 2014 at 1:14 AM, Roelof Wobben rwob...@hotmail.com wrote:
I have read all comments and im a little bit
On 13/01/14 18:22, Peter Otten wrote:
Peter Otten wrote:
In the mean time here is my candidate:
def test(a, b):
a = iter(a)
return all(c in a for c in b)
That's pretty close to my original thoughts. But one question.
Why explicitly convert string a to an iter? The 'in' test
would
On Mon, Jan 13, 2014 at 1:36 PM, Keith Winston keithw...@gmail.com wrote:
Yikes, Peter, that's scary. Wow.
Yikes, watch the top posting. :)
In the mean time here is my candidate:
def test(a, b):
a = iter(a)
return all(c in a for c in b)
Refer to the language reference discussion
Alan Gauld wrote:
On 13/01/14 18:22, Peter Otten wrote:
Peter Otten wrote:
In the mean time here is my candidate:
def test(a, b):
a = iter(a)
return all(c in a for c in b)
That's pretty close to my original thoughts. But one question.
Why explicitly convert string a to an
s*** just got real.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
: , fix_machine('wsx0-=mttrhix', 't-shirt') == 't-shirt'
Roelof
To: tutor@python.org
From: alan.ga...@btinternet.com
Date: Sun, 12 Jan 2014 00:45:11 +
Subject: Re: [Tutor] another better way to do this ?
On 11/01/14 21:24, Roelof Wobben wrote:
I have two strings a and b
Now I have
On 12/01/14 08:12, Roelof Wobben wrote:
# Write a Python procedure fix_machine to take 2 string inputs
# and returns the 2nd input string as the output if all of its
# characters can be found in the 1st input string and Give me
# something that's not useless next time. if it's impossible.
OK
Alan Gauld wrote:
On 12/01/14 08:12, Roelof Wobben wrote:
# Write a Python procedure fix_machine to take 2 string inputs
# and returns the 2nd input string as the output if all of its
# characters can be found in the 1st input string and Give me
# something that's not useless next time. if
Roelof Wobben rwob...@hotmail.com Wrote in message:
That documentation says nothing about order. And the test cases
specifically contradict it.
so try
if set (b) = set (a):
--
DaveA
Android NewsGroup Reader
http://www.piaohong.tk/newsgroup
On Sun, Jan 12, 2014 at 8:21 AM, Peter Otten __pete...@web.de wrote:
OP: You'll get bonus points (from me, so they're pointless points, but
still) if you can solve this (including the fifth apocryphal test case)
using the collections.Counter class.
Hint:
print(Counter.__sub__.__doc__)
On 12/01/14 14:43, Dave Angel wrote:
so try
if set (b) = set (a):
Ooh, nice! For some reason I've never thought of
applying set to a string before.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
On Sun, Jan 12, 2014 at 7:44 AM, Alan Gauld alan.ga...@btinternet.com wrote:
OK So there is nothing here about the orders being the same.
That makes it much easier.
There's another approach, I think, that's quite easy if order IS important.
Iterate through the letters of product, find() them
On 12/01/2014 19:22, Keith Winston wrote:
On Sun, Jan 12, 2014 at 7:44 AM, Alan Gauld alan.ga...@btinternet.com wrote:
OK So there is nothing here about the orders being the same.
That makes it much easier.
There's another approach, I think, that's quite easy if order IS important.
Iterate
OOps, I never used the success boolean in my code, but forgot to
remove it. Sorry.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston keithw...@gmail.com wrote:
if test:
Sigh and this line needs to read (if it's going to do what I said):
if test != -1:
--
Keith
___
Tutor maillist - Tutor@python.org
To
On Sun, Jan 12, 2014 at 2:38 PM, Keith Winston keithw...@gmail.com wrote:
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston keithw...@gmail.com wrote:
if test:
Sigh and this line needs to read (if it's going to do what I said):
if test != -1:
Consider the case of `product
On Sun, Jan 12, 2014 at 2:38 PM, Keith Winston keithw...@gmail.com wrote:
Sigh and this line needs to read (if it's going to do what I said):
As Alan pointed out, the examples provided do NOT account for order,
so if one uses my (corrected) algorithm, you get different results
from the
On 01/12/2014 06:43 AM, Dave Angel wrote:
Roelof Wobben rwob...@hotmail.com Wrote in message:
That documentation says nothing about order. And the test cases
specifically contradict it.
so try
if set (b) = set (a):
or, as the OP specified, if order is relevant,
def test(a,b):
for ii
Emile van Sebille wrote:
On 01/12/2014 06:43 AM, Dave Angel wrote:
Roelof Wobben rwob...@hotmail.com Wrote in message:
That documentation says nothing about order. And the test cases
specifically contradict it.
so try
if set (b) = set (a):
or, as the OP specified, if order is
On 01/12/2014 12:21 PM, Peter Otten wrote:
test(axbxc, abc)
True
test(abbxc, abc)
False
Is the second result desired?
No -- the second should match -- you found a test case I didn't...
def test(a,b):
for ii in a:
if ii not in b: a=a.replace(ii,)
while ii+ii in a:
Emile van Sebille wrote:
On 01/12/2014 12:21 PM, Peter Otten wrote:
test(axbxc, abc)
True
test(abbxc, abc)
False
Is the second result desired?
No -- the second should match -- you found a test case I didn't...
def test(a,b):
for ii in a:
if ii not in b: a=a.replace(ii,)
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston keithw...@gmail.com wrote:
There's another approach, I think, that's quite easy if order IS important.
Alas, there's one further problem with my script, relating to testing
multiple sequential letters in product... but I'm not going to say
more,
On 11/01/14 21:24, Roelof Wobben wrote:
I have two strings a and b
Now I have to check if the characters of b are all in a.
But they do have to be in the same order.
I'm not sure exactly what you mean? Can you give some examples of
data that pass and that fail the criteria?
Your algorithm
Hello,
I try to learn python by following the audicity page.
Now I have the following problem.
I have two strings a and b
Now I have to check if the characters of b are all in a.
But they do have to be in the same order.
So I thought about this solution.
length = len(b)
start = 1
On Jan 11, 2014, at 4:24 PM, Roelof Wobben wrote:
Hello,
I try to learn python by following the audicity page.
Now I have the following problem.
I have two strings a and b
Now I have to check if the characters of b are all in a.
But they do have to be in the same order.
29 matches
Mail list logo