<br><br><div class="gmail_quote">On Sat, Jun 25, 2011 at 9:38 PM, Alan Gauld <span dir="ltr"><<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
"naheed arafat" <<a href="mailto:naheedcse@gmail.com" target="_blank">naheedcse@gmail.com</a>> wrote<div class="im"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
1)<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' '))<br>
</blockquote></blockquote></blockquote>
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am<br>
</blockquote></blockquote></blockquote>
fine.'.split(' '))<br>
[('you?', 'i'), ('are', 'am'), ('How', 'fine.')]<br>
<br>
Which one has better efficiency?<br>
</blockquote>
<br></div>
Why not just measure it with timeit?<div class="im"><br>
<br></div></blockquote><div> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
2)<br>
Is there any way easier to do the following?<br>
input:<br>
'How are you'<br>
'I am fine'<br>
output:<br>
'you I are am How fine'<br>
<br>
solution:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
' '.join(reduce(lambda x,y:x+y, zip('How are you'.split(' ')[::-1],<br>
</blockquote></blockquote></blockquote>
'I am fine'.split(' '))))<br>
</blockquote>
<br></div>
That depends on your efiition of easier<br>
There are clearer solutions but they will be more verbose.<br>
Do you measure "easiness" by readability, or by typing effort?<br>
Or something else?<br>
<br>
Alan G<br>
<br>
<br></blockquote><div>Here I meant the term "easier" by conceptually easier.. I mean any Conceptually neater way other than the following steps: <br> for the given input:<br> 1. ['you', 'are', 'How']<br>
2. ['I', 'am', 'fine']<br> 3. [('you', 'I'), ('are', 'am'), ('How', 'fine')]<br> 4. ('you', 'I', 'are', 'am', 'How', 'fine') i.e applying + operator cumulatively.<br>
sorry for my english.<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
______________________________<u></u>_________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/tutor</a><br>
</blockquote></div><br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>