<br><br><div class="gmail_quote">On Sat, Jun 25, 2011 at 9:38 PM, Alan Gauld <span dir="ltr">&lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt;</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>
&quot;naheed arafat&quot; &lt;<a href="mailto:naheedcse@gmail.com" target="_blank">naheedcse@gmail.com</a>&gt; 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(&#39;How are you?&#39;.split(&#39; &#39;)[::-1],&#39;i am fine.&#39;.split(&#39; &#39;))<br>
</blockquote></blockquote></blockquote>
[(&#39;you?&#39;, &#39;i&#39;), (&#39;are&#39;, &#39;am&#39;), (&#39;How&#39;, &#39;fine.&#39;)]<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),&#39;How are you?&#39;.split(&#39; &#39;)[::-1],&#39;i am<br>
</blockquote></blockquote></blockquote>
fine.&#39;.split(&#39; &#39;))<br>
[(&#39;you?&#39;, &#39;i&#39;), (&#39;are&#39;, &#39;am&#39;), (&#39;How&#39;, &#39;fine.&#39;)]<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>
&#39;How are you&#39;<br>
&#39;I am fine&#39;<br>
output:<br>
&#39;you I are am How fine&#39;<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;">
&#39; &#39;.join(reduce(lambda x,y:x+y, zip(&#39;How are you&#39;.split(&#39; &#39;)[::-1],<br>
</blockquote></blockquote></blockquote>
&#39;I am fine&#39;.split(&#39; &#39;))))<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 &quot;easiness&quot; by readability, or by typing effort?<br>
Or something else?<br>
<br>
Alan G<br>
<br>
<br></blockquote><div>Here I meant the term &quot;easier&quot; by conceptually easier.. I mean any Conceptually neater way other than the following steps: <br>   for the given input:<br>     1. [&#39;you&#39;, &#39;are&#39;, &#39;How&#39;]<br>
     2. [&#39;I&#39;, &#39;am&#39;, &#39;fine&#39;]<br>     3. [(&#39;you&#39;, &#39;I&#39;), (&#39;are&#39;, &#39;am&#39;), (&#39;How&#39;, &#39;fine&#39;)]<br>     4. (&#39;you&#39;, &#39;I&#39;, &#39;are&#39;, &#39;am&#39;, &#39;How&#39;, &#39;fine&#39;) 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>