s*** just got real.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
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
On Mon, Jan 13, 2014 at 1:36 PM, Keith Winston 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 of compari
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
> 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 wrote:
> > I have read all comments a
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
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 t
On Mon, Jan 13, 2014 at 1:14 AM, Roelof Wobben 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 the capacity, with w
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
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston 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, I'll leave it as a pro
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:
> i
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: a=a.r
Emile van Sebille wrote:
> On 01/12/2014 06:43 AM, Dave Angel wrote:
>> Roelof Wobben 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 rel
On 01/12/2014 06:43 AM, Dave Angel wrote:
Roelof Wobben 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 in a:
if ii no
On Sun, Jan 12, 2014 at 2:38 PM, Keith Winston 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 examples. Without the f
On Sun, Jan 12, 2014 at 2:38 PM, Keith Winston wrote:
> On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston 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 == "letter"`. Do you want to doub
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston 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 unsubscribe or change subscr
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 12/01/2014 19:22, Keith Winston wrote:
On Sun, Jan 12, 2014 at 7:44 AM, Alan Gauld 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 pr
On Sun, Jan 12, 2014 at 7:44 AM, Alan Gauld 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 initially from the
begi
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 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__.__
Roelof Wobben 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
___
Tutor ma
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 nex
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
;Udacity') == 'Udacity'
print "Test case 3: ", fix_machine('AEIOU and sometimes y... c', 'Udacity') ==
'Udacity'
print "Test case 4: ", fix_machine('wsx0-=mttrhix', 't-shirt') == 't-shirt'
Roelof
&g
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 ord
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
wh
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 be
29 matches
Mail list logo