/log

life.log()

Archive for the ‘Python’ tag

biggest prime palindrome under 1000.

with 4 comments

I had that problem in CodeEval:

Write a program to determine the biggest prime palindrome under 1000.

And my solution passed i don’t know if they have other levels than pass but it passed anyway..

Here you are:

oddNumbers 		= [2] + range(3, 1000, 2)
primeNumbers	= []
ppNumbers 		=[]
for item in oddNumbers:
	isPrime = True
	for otherItem in oddNumbers:
		if item % otherItem == 0 and item != otherItem:
			isPrime = False
	if isPrime:
		primeNumbers.append(item)

for prime in primeNumbers:
	if prime > 100 and str(prime)[0] == str(prime)[2]:
		ppNumbers.append(prime)

print ppNumbers[-1]

I first created script to get prime numbers then i search to know what exactly a palindrome number is and i tweaked the script to solve it:)

The personal part of the post:
I -lately- figured out that family support is not only important .. it’s incomparable to any other support..

ربنا يخليك ليا يا بابا
سلام

Written by me

August 16th, 2011 at 2:14 pm

Posted in I code,me.status()

Tagged with , , ,

yield statement .. by example

with 2 comments

السلام عليكم و رحمة الله وبركاته

ده تمرين بسيط علىyield statement

def simpleGenerator( anyList ):
	for item in anyList:
		yield item

myList = ['Ahmed', 'AlSayed', 'AbdulHameed', 'Osama', 'Gamal']

nameGenerator =  simpleGenerator( myList )

for name in myItemsList:
	print name

print myItemsList.next()
print myItemsList.next()
print myItemsList.next()
وده بس عشان البلوج كان عشش فيه العنكبوت ..

Written by me

June 27th, 2010 at 9:45 pm

Posted in I code,software

Tagged with ,

محاضرتي القادمة

without comments

السلام عليكم و رحمة الله و بركاته

بعد غيبة طويلة أنا و الكات سكوب راجعين مع بعضأيون.. دي النسخة ال١١ من المؤتمر أيام ١٢،١٣،١٥، ١٦ أربعاء خميس سبت و الأحد القادمين..

و أنا سعيد جدا إني هعمل محاضرة فيه  يوم الخميس إن شاء الله …. و نفسي جدا ينجح لأكتر من سبب .. من أهمهم..

١-نشر المعرفة و بالذاتالمرة دي وإحنا إتكلمنا مع شباب من إعدادي و أولي هندسة و بالتالي الثواب إن شاء الله كتير..

٢-تتويج لجهود الشباب اللي إتطحنوا واللي لأول مرة ببقى بعيد عنهم في حاجة زي كده .. لكن البركة في الشباب  عاملين شغل فوق الممتاز حتى الآن و على رأسهم محمد صفوت الcoordinator.  بيفكرني بنفسي في شبابي شمعة تحترق من أجل الآخرين ..

٣- عشان نفسي فكرة الCAT  تسود ونبقى في يوم من الأيام عندنا منظمة كده كبيرة والناس بتقلدها .. عشان حتى و إحنا مش شاغلين نبقى بناخد حسنات و فضل و فتوحات دنيا و آخرة إن شاء الله ببركة بداية العمل  و الصبر عليه..

زي ما قلت.. هحاضر إن شاء الله في المؤتمر يوم الخميس -بعد بكره-١٣ مايو ٢٠١٠ الساعة ١١ صباحاً.

المحاضرة بعنوان Google App Engine

المكان : في قاعة أ.د رشاد البدراوي في كلية الهندسة جامعة المنصورة.

الموقع الإلكتروني للمؤتمر:

http://catreloaded.net/scope

المحاضرين الآخرين  :
http://scope.catreloaded.net/speakers

الجدول :

http://scope.catreloaded.net/schedule

الموقع عموماً هنضيف في الأيام الجاية المحاضرات بمواعيدها بالظبط في التقويم الجوجلي للفريق ..و هنعلنه بحيث إنك لو عايز تنبيه يجيلك على البريد أو على الموبايل قبل كل محاضرة ..

كمان بنحاول نشوف حل لبث المؤتمر كله حي و مباشر من موقع الحدث على ustream.tv m لذلك ترقب الآحداث..

خد نصيحتي كمان أجيبلك من الآخر.. تابع بقية الأخبار على تويتر :

www.twitter.com/CAT_SCOPE

وعلى مجموعتنا على الFacebook

http://www.facebook.com/#!/group.php?gid=11705900412

*زي اليوم ده من ٣ سنين إديت محاضرة هي كانت أول محاضرة أديها ل CSED والحضور اللي كان فيها كان مميز جدا بالنسبة لي و أنا فاكر كويس حصل بعديها مشاكل مع محمد حمدي إنه كان مقتنع إن الإجتماع مكنش مُجدي أو حاجة زي كده .. مش فاكر أوي أنا فكاكر إن كان في مشاكل ..

على أي حال عمري ما هنسى اليوم ده و قد إيه انا كنت سعيد فيه .. والوقتي بقى بعد ٣ سنين إكتشفت إن يمكن الفرحة العرمة اللي كنت فيها هي السبب إني كنت ملبخ ؟؟!! ممكن والله

أحمد سليمان و أحمد عبدالله و أحمد على بكساوي و لفيف من أقوى رجال الفريق القدامي هيعملو برده محاضرات جنباً إلى جنب مع شباب الجيل الصاعد شباب حاسبات اللي لعبوا دور جامد جدا السنين اللي فاتت  ده طبعا إلى جانب ولأول مرة ناس مش من الفريق دائمين زي أحمد كاوي و أحمد علي التاني و زي محمد جمال دول بقى ناس جديدة جامدة و مش تبع الرعاة و اللي هيا حاجة جديدة جدا جدا من نوعها .. و لأول مرة في اللينكس أحمد بيه بكر صديق الكفاح .. يعني كلام جديد حديد جديد حديد ..

*٣ المؤتمر ٤ أيام دسمة جدا جدا تقنياً لو أنت من بره المنصورة و بتفكر تيجي فعلا فرصة كويسة .. و مش هتندم إن شاء الله ..

Written by me

May 11th, 2010 at 10:13 am

Primes Problem in Python

with 10 comments

السلام عليكم و رحمة الله و بركاته

Lately I decided to give SPOJ website a try ..
And my first problem after the TEST problem was the “PRIME1” problem..
Which is basically finding the prime numbers between 2 given numbers ..

Yesterday, regardless the fact of being truly ill and I hardly could open my eyes ..
I decided to solve the problem ..

and after I think 1 hour It started to output relatively right solution ..

here is my code in python:

times = input()
while times > 0:
    times -= 1
    limits = raw_input()
    limits = limits.split(" ")
    downLimit = int(limits[0])
    upLimit = int(limits[1])
    numsList = []
    numsList = [i for i in range(downLimit,upLimit) if (i%2 or i==2) and i != 1 and i!=0]
    primesList = list(numsList)
    for oddNumber in numsList:
        primeNumber = True;
        for number in range( 2 , oddNumber / 2):
            if oddNumber % number == 0:
                primeNumber = False;
                break;

        if not primeNumber:
            primesList.remove( oddNumber )

    for primeNumber in primesList:
        print primeNumber

Notes:
1-in line 9, I used list() to assign the numsList value to the primesList list .. not the numsList as python-strangely- assigns the old list reference to the new list and that caused +1 hour of debug .. :@
2-As shown in page title after submitting the problem they replied that solution exceed the time limit .. so any help will be appreciated ..
3-Python version 2.6.2 on Mac

Written by me

February 5th, 2010 at 11:39 am

Posted in I code,software

Tagged with , ,

Back ..digest

with 10 comments

Al Salam 3lykom :)

This is me again after 5 -or more- months of silence ..

here is the digest as usual:

-Python Course is done ..great course and all course members were as cute as python… python the language :D
-My Acer Lap is out of service .. my LED has gone .. The PHP Course at UTC is done
>This prevented me from presenting from my lap in Hackers Duo.
>My Hackers Duo Session was “Python for PHP programmers”
>sudden foto from my session I gained some weight.
My full session

-Tadabbor work with maher .. we are doing great and I think he is satisfied working with me. special course with a nice bro. Eng.Alaa, Eslam,Ramy and Ahmed AbuHazz.

-Ramadan 22Aug, ” kol sana wenta tayeb ” has 2 meanings …

-Ahmed Nasr 3 websites are finally done in about 1 month… and a suspended Course at his home..same course above.

-I bought my Vodafone USB modem to be able to work anywhere, specially in AlTagdeef Club with Nasr..

-CAT Iftar II .. Ahmed Soliman said that I’m a reference in my career as well as being happy that we are friends .. which is really great thing specially that it was in public.. and here I’m re-announcing that Ahmed Soliman is my real teacher..

-My Laptop is fixed welcome back ya Joe :D and My MacBook Pro 13” is at home :)

-E3tkad MasJed AlSalab, lots of new friends and real friends I guess and Arch. Friends ..

-3akef.com Idea, Dr.Ahmed Saif Visited me at home, and I met dr.Hazem Shouman and updated his mobile with Bakr.

-CAT trials to motivate the community ..

-Resuming courses..Back to study..

-Crash study, thanks to swine flue.

-exams and course simultaneously

-I won’t get the full marks of the XOR problems I invented myself :D ..

-Al WaQfa, Nassar had a cute baby girl and they called her Hana هنا  and a meeting for:
Ahmed Abdullah, Ahmed Soliman, Kamasheto, Nassar, Ahmed Bakr, Metoo, Ayman Taher and me :D in AlTagdef.

-Eid AlAdHa 2nd day we met again without Abdullah but with Safwat and osama and snap and daif and then Sinar and her sisters joined us on Bahgat and Samir.

-Now, I’m thinking about mainly few things:

-Back to Quran and be more strict .. 3akef.com as a semantic, personalized web2.0 Islamic website.

-The fact that the most painful areas in my body are my head and my heart  .. except that my heart pain is always resolve to non-scientific non-deterministic problem
Specially that when I noticed that last year witnessed lots of people losses .. :(

-2010 plans and hopes ..
Specially that 7-12 proved it’s kind of reliable framework and I have lots and lots of ideas to improve it ..:-|

-Losing weight

-My transportation problem and the social acceptance .. buying a CAR.

يا رب وفق

ملحوظة للمتابعين ان كان في لسه متابعين .. انا بكتب جزء كبير من التقنيات والعمل التقني على الهاكرز…
egamal.n.cat-hackers.net

و السلام عليكم و رحمة الله و بركاته

Written by me

November 30th, 2009 at 10:53 am

Get Adobe Flash playerPlugin by wpburn.com wordpress themes