color version - PET: Python Entre Todos - Python Argentina
color version - PET: Python Entre Todos - Python Argentina
color version - PET: Python Entre Todos - Python Argentina
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>PET</strong> Challenge<br />
Authors: Juanjo Conti y Alejandro Santos<br />
In the previous <strong>PET</strong> issue we presented our first challenge: provide the shortest program<br />
capable of factoring a number (taking some rules into account). We received a lot or<br />
responses, the first ones around 500-characters long, the last ones squeezing every byte<br />
out of the code to get the shortest solution.<br />
From the 58 participants we had, we are proud to tell that we had 3 winners. What’s<br />
more, their 111-character long solutions get the same results in different ways, cutting,<br />
massaging and perfecting their original solutions.<br />
The winners<br />
Without further ado, the winners and their solutions are:<br />
Chema Cortes with pet1-pych3m4.py:<br />
n=input();d=1;r=""<br />
while di:<br />
c=0;i+=1<br />
while 1>s%i:c+=1;s/=i<br />
if c:_+=' x '+`i`+'^%i'%c*(c>1)<br />
Oswaldo Hernández with pet1-hdzos.py:<br />
n=input()<br />
d,f="",1<br />
while n>1:<br />
f+=1;r=0<br />
while n%f1)<br />
Special mention<br />
In this opportunity we have considered awarding the “most cheating” award to Darni,<br />
that asked us not to rename his file “pet1-darni.py” but use his artistic pseudonym:<br />
ZT1pbnB1dCgpCnM9JycKZD0xCndoaWxlIGU+MToKCXA9MDtkKz0xCgl3aGlsZSBlJWQ8MTplLz1kO<br />
So this is the content of the file<br />
pet1-ZT1pbnB1dCgpCnM9JycKZD0xCndoaWxlIGU+MToKCXA9MDtkKz0xCgl3aGlsZSBlJWQ8MTplL<br />
import base64;exec(base64.decodestring(__file__[5:-3]))<br />
Additional information about the competition can be found at<br />
http://python.org.ar/pyar/Proyectos/Revista<strong>Python</strong>Comunidad/<strong>PET</strong>1/Desafio<br />
New challenge<br />
This new challenge was written by Alejandro Santos, who loves problem solving and<br />
spent the last week sending several puzzles to the PyAr list.<br />
Thanks to Matías “Tuute” Bellone for his revision of the problem’s first draft.<br />
The QQQ number<br />
QQQ is the most popular social network of the Ainohtyp country. Microblogging-style<br />
QQQ is a social network where users can only post the word “QQQ”. The users can also<br />
have other users as contacts, but the other user has to do so too.<br />
The network’s administrators built a list with the user sorted by the amount of contact.<br />
Curly is at the top of the list with the most contacts.<br />
Your job is to create a program that finds the minimum distance between each user and<br />
Curly. That is, the minimum amount of hops between Curly and the rest of the users. If<br />
there is more than one way, the shortest is chosen.<br />
For example, lets say Curly is friends with Larry and Moe, Larry is friends with Sue and<br />
Sue is friends with Curly. Sue has a distance of 1 with Curly and Larry and Moe have a<br />
distance of 1 as well.<br />
It is possible to get from Curly to Sue through Larry, but as Sue is friends with Curly the<br />
minimum distance is 1. But if Howard is friends with Moe then the minimum distance<br />
from Curly to Howard is 2 as you need to jump through Moe.<br />
Input data<br />
All data must be read through standard input.