Jobs/Vacancies › Re: BAT Test By Kimberly-Ryan by tundebabzy: 6:55pm On Jul 18, 2011 |
Hi guys. Anymore updates especially from those who did the interview in Abuja? |
Programming › Re: Coding Challenge 6: Working With Arrays by tundebabzy: 12:59pm On Jul 17, 2011 |
can someone explain to me how to avoid being blocked by nairaland's s.t.u.p.i.d. bot |
Programming › Re: Coding Challenge 6: Working With Arrays by tundebabzy: 7:27am On Jul 17, 2011 |
Nairaland has to train its spambot. It kicked me out again yesterday. And at least nairaland could give a helpful less annoying reason instead of 'reason: you were blocked by anti-spam bot, ' Anyway, My solution using python. First of all, python does not have arrays. Its data structure similar to arrays is Lists and the difference is that objects of different types including other types of data structures can be stored in a single lists. Also, python allows you to create static methods by using the 'staticmethod' decorator. I've commented my code so it should be easy to understand Constructive (extremely inefficient and has the potential to run for ages): class C: @staticmethod def load_shed_d(l, num): """ C.load_shed_d(3,4,5,6,7],7)------>6 This function takes a list and an integer and returns the number closest to the given number. """ highest = 0 for x in range(len(l)): if l[x] > highest and l[x] < num: highest = l[x]
return highest
since its a static method, you can run thus: C.load_shed_d(list, int). With the example given it runs in 0.0 second For the efficient (destructive) solution: class C: @staticmethod def load_shed(l, num): """ C.load_shed([3,4,5,6,7],7) ----> 6 This function takes a list and an integer and returns the number closest to the given number. """
l = sorted(l) #sort ascending to make things easier cache = l for count in range(len(l)): size = len(cache) #needed so the list can be divided into 2 up = cache[ size/2)] # The first half of the list down = cache[size/2:] #The second half of the list # If the highest num in up is less than the least num in down # and if the least num in down is greater than the given int, if max(up) < min(down) and min(down) >= num: return max(up) elif max(up) > num: cache = up # Shed the 2nd half of the list else: cache = down # Shed the 1st half of the list
With the example given runs in 0.0 seconds omo_to_dun: but I want a community where we can help one another to become better programmers, not better copy and paste geniuses. And yes, naija_swag, NL needs your expertise. Please, come back. +1 |
Programming › Re: Coding Challenge 6: Working With Arrays by tundebabzy: 1:20am On Jul 17, 2011 |
Python doesn't have arrays. Python's similar data structure is called Lists and the difference is that objects of different kinds can be stored in one list. In python, a static method can be created easily by using the "staticmethod" decorator so that a method - static() in a class - F can be called without instantiating the class like this: F.static() Anyway this is my solution: destructive (and by far fastest: class C: @staticmethod def load_shed(l, num): """ C.load_shed([3,4,5,6,7],7) ----> 6 This function takes a list and an integer and returns the number closest to the given number. """ l = sorted(l) #sort ascending to make things easier cache = l for count in range(len(l)): size = len(cache) #needed so the list can be divided into 2 up = cache[ size/2)] # The first half of the list down = cache[size/2:] #The second half of the list # If the highest num in up is less than the least num in down # and if the least num in down is greater than the given int, if max(up) < min(down) and min(down) >= num: return max(up) elif max(up) > num: cache = up # Shed the 2nd half of the list else: cache = down # Shed the 1st half of the list
For the constructive (very inefficient because it loops through the whole list): class C: """ C.load_shed_d(3,4,5,6,7],7)------>6 This function takes a list and an integer and returns the number closest to the given number. """ @staticmethod def load_shed_d(l, num): highest = 0 for x in range(len(l)): if l[x] > highest and l[x] < num: highest = l[x]
return highest
|
Programming › Re: Coding Challenge 5: Substring Generator by tundebabzy: 9:05am On Jul 16, 2011 |
sorry, nairaland-bot refused to inform me that you had replied
no-recursion: rum---------------> r ru rum u um m "" fayimora---------> f fa fay fayi fayim fayimo fayimor fayimora a ay ayi ayim ayimo ayimor ayimora y yi yim yimo yimor yimora i im imo imor imora m mo mor mora o or ora r ra a ""
iterative recursion: rum---------------> r u m ru um rum "" fatimora---------> f a y i m o r a fa ay yi im mo or ra fay ayi yim imo mor ora fayi ayim yimo imor mora fayim ayimo yimor imora fayimo ayimor yimora fayimor ayimora fayimora ""
P.S i've edited my post to take care of some redundancies |
Programming › Re: Coding Challenge 5: Substring Generator by tundebabzy: 2:11pm On Jul 15, 2011 |
with python code: def nairaland(word): #w = []-----------> redundant. I forgot to delete for x in range(len(word)): t = x for j in range(1,len(word[x:])+1): print word[t:t+j] print '""'
If you must have a recursion: def nairaland_r(word, flag=1, w=None): #if not w: ---->redundant # l = [] #else: # l = w if flag > len(word): print '""' else: for x in range(len(word)): print word[x:x+flag] if x+1 > len(word)-flag: break f = flag + 1
nairaland_r(word,f,l)
Edit: def nairaland(word): for x in range(len(word)): t = x for j in range(1,len(word[x:])+1): print word[t:t+j] print '""'
def nairaland_r(word, flag=1): if flag > len(word): print '""' else: for x in range(len(word)): print word[x:x+flag] if x+1 > len(word)-flag: break f = flag + 1
nairaland_r(word,f)
|
Programming › Re: New Programming Challenge by tundebabzy(op): 9:49am On Jul 15, 2011 |
Challenge complete! Your CPU must be cooled by a giant heatsink.
Please email us what you thought of the challenge and the code you used to solve it at the unique email below. Also - we're hiring! Send us a resume or link to your github account!
ajobwelldone+ffb28@readyforzero.com
What did you think? |
Programming › Re: Creating A New Face For Nl by tundebabzy: 11:19pm On Jul 11, 2011 |
omo_to_dun: @ tundebabzy
I have read tons of your comments and you are an intelligent guy, and I also disagree with on this issue. As simple as NL seems, it would be a lot of hard work to recreate without using a CMS; do you know of any Nigerian forums that were built from the ground up? I did not mean to be disrespectful to Nigerian programmers who labor everyday to gain knowledge and to put food on their tables; I only gave an honest assessment about the level of skills of the average Nigerian programmer. We still have a long way to go. I totally agree with you that most Nigerian programmers are average. That is not because they(we) are Nigerian but because of the environment they(we) find themselves(ourselves). I have a classmate who is an engineer in facebook. He works on privacy. He left naija to study in howard uni and before leaving Nigeria, he never ever tried to program. |
Programming › Re: Creating A New Face For Nl by tundebabzy: 10:11pm On Jul 11, 2011 |
binkabir: Django is a python web framework and is very cool i have worked with it some years back (2006). but i personally prefer Yii framework from PHP http://yiiframework.com Frameworks of any language make such projects very easy. Ruby on rails would more or less be like magic so guys, please dont run down everyone, to be honest, recreating this site wouldn't be half as challenging as its being made to seem. |
Programming › Re: Creating A New Face For Nl by tundebabzy: 8:46pm On Jul 11, 2011 |
 Has anyone here heard of web frameworks? A django expert will recreate this site in less than a week plus django is free, very popular and open source. Updates to the framework are pushed when new security tricks are discovered. The only thing I know MIGHT be hard to recreate is the amount of traffic on nairaland #shikena |
Politics › Re: Lagos Flood: Fashola Declares Monday Public Holiday by tundebabzy: 8:20pm On Jul 11, 2011 |
hbrednic: they are all asslickers sammirano: they will die in the water in their bedroom singing praises of fashola. Sun of god: Fashola - Tender Your Resignation You are all sick idiots, extremely dumb. Your statement shows your brains will be too small to fit into an ampiclox capsule and each of you definitely have the IQ of a brick. I'm no longer following the topic so don't even bother to reply |
Programming › Re: Coding Challenge 2: Palindromes by tundebabzy: 2:04am On Jul 07, 2011 |
python solution:
<code> import time
def check_palin(st): t1 = time.time() stripped = "" for ch in st: if (ord(ch) > 64 and ord(ch) < 91) or (ord(ch) > 96 and ord(ch) < 123): stripped += ch t2 = time.time() print 'running time is %f' %(t2-t1)
return stripped.lower() == stripped[::-1].lower() </code>
Ideally I would have imported re so i can use regular expressions to strip any non-alphabet from the string instead of looping character by character. |
Programming › Re: New Programming Challenge by tundebabzy(op): 12:56am On Jul 07, 2011 |
Fayimora: I left that project euler after 20 problems cause its all maths, no berra challenge Yup I agree, and for some of the questions, you just can't solve them by brute force efficiently. |
Programming › Re: Coding Challenge 3: Sum Of Primes by tundebabzy: 12:54am On Jul 07, 2011 |
hahaha. This is a project euler question |
Programming › Re: New Programming Challenge by tundebabzy(op): 12:47am On Jul 07, 2011 |
i think I am the only netizen with username tundebabzy, and I have been trying my hands on project-euler, And thanks, i'm seriously expecting your input. I should be sleeping now but let me see what I can do to fayimora's homework |
Jobs/Vacancies › Re: BAT Test By Kimberly-Ryan by tundebabzy: 6:25pm On Jul 06, 2011 |
I wrote my test 2nd June. Relax guys, didn't you notice that all of you guys that did your interview earlier were those in Lagos area? |
Jobs/Vacancies › Re: BAT Test By Kimberly-Ryan by tundebabzy: 8:03pm On Jul 05, 2011 |
July 13, Abuja |
Jobs/Vacancies › Re: BAT Test By Kimberly-Ryan by tundebabzy: 6:15pm On Jul 05, 2011 |
errrr, I just got an invitation for BAT interview, |
Programming › Re: Google Hacking For Information by tundebabzy: 5:48pm On Jul 05, 2011 |
|
Programming › Re: New Programming Challenge by tundebabzy(op): 7:14am On Jul 04, 2011 |
Mobinga:
 Lol, I also saw that |
Programming › Re: Google Hacking For Information by tundebabzy: 7:05am On Jul 04, 2011 |
Slyr0x: I disagree with this bro. .'Cos a plane was used during the 9/11 attack doesn't make the plane bad.
Narrowing it down, Hacking IS NOT bad. .the intention is! #GBAM Number_One: Dude, lets not confuse ourselves with english, lets leave that for the English folks. Hacking used to be good, now its not. Saying that its still good is just denial. Before now phones were JUST for making/receiving calls. Now they do much more, browsing, multimedia etc. To insist that phones are JUST for calls will not be correct. It was then, not anymore. Hacking was cool then, not anymore.  Dude what are you saying. Now smartphone and land phone have been added to the dictionary. I guess that proves to you that there are different kinds of hacking, duhhhhhh! |
Programming › Re: New Programming Challenge by tundebabzy(op): 1:01am On Jul 03, 2011 |
tundebabzy: The following text is an in-order traversal of a binary tree with 1023 nodes. What is the sum of the digits appearing in the leaves?
bDq4i3eFNmjh2oMgjNsIFkRWsonRl=tz9kf8gOpED2gVQrfx49GjR9/QNqTEJkSzM30p4RfneDc7EmdusIYdxxZ8KKdND==YpLlmN/FkErS7uqVHYIyGEBIhIRX+mbg6FjVGqfYjobX3F1lSmPpLXXxhux1lV=EzIgGct9pd=ogzAdJU4/yZOj9=njfvbSo11bcE/yUDHg/J=6DAtmWt+P/VDvE4GyYHlKVGUoksn+Lzm6Y1VVF6qw=onnKZS=CQQUPeMlUGtMobJEeyIyGBMFj5kHml1waI97qgVt/yeKWSXxhJyK+As0M0UR2KL+U7klKMlWlxgbIJ2beN0gaMHbIClKrBuroo+L73CwnbFKRiyKOx8Ke=PPukm1BWYd4Do5nikrT0dgPWlmItCzyZrEiOBgBtEB9FG1qdQJud182qYU4Xwry=bR7R5PH=Npab7JQ7gY=MYHW24iw=m2+XayIachr=QVt4giclLluUEu3Dx/5y7R0GlINqoJc9O6QwEP6a9PRsdt86nZYQUF/b729lzilkM1PB8mDPACTOGobXSJJQshRQCoJoC9TX6ERou/tlMWNQTaaU0YmzIFh8t72lgOeIMu4W2S9V8Y5jO8T47ZPRGxeQDWRQlpx1tc3AC4+x2zJxZaYV6d4+rxxWgYnYC1ZwUvXNF2YLaRw7ldRXCz9/7xZ3mKBj4Ox51L3PqGXAIB+OI4pgkUc1X52tOPdRPgpsfi8wNpynfylwjITvNKq93iViQiyiEVGBgazbHQ7boh5tejStBE1SCk1fMe1=ycNoxJzhAH4x/YlQSUOz/2qkl+JxFBt8sqRYXZjZ6R=Gh87ZwS4B0Meo56/WF+40bf2mTgG05KQ/qR89NMyttHdwwnzvkZuXGrlt/yuStJaXJNkqQ5atDPWqLJy4Q9iylEdI3qmTe6Wmou/umQG7Q+aiOXorJde3Z4CzMyTYnCWvudFDZvgEZsuKRiSOurstnxFRlqVQ0LC7WRuS=qCsDcxoDT5dl9NHusV4kZ/ I finally solved this question and it was surprisingly easy. You can check my site for the solution and give suggestions for a more elegant solution http://scrabala.com/stories/2011/jul/02/readyforzero-challenge-solution-problem-2/ |
Programming › Re: Google Hacking For Information by tundebabzy: 5:24pm On Jul 02, 2011 |
Number_One: Hacking Defined: Hacking is unauthorized use of computer and network resources. (The term "hacker" originally meant a very gifted programmer. In recent years though, with easier access to multiple systems, it now has negative implications.)
Hacking is a felony in most other countries. When it is done by request and under a contract between an ethical hacker and an organization, it's OK. The key difference is that the ethical hacker has authorization to probe the target. While hacking is greatly associated with security break ins nowadays, that is not the only definition of hacking. Hacking (The real definition) generally means exploring the details of a programmable system and stretching its capabilities. Those hackers that break in to security systems are basically doing the same, exploiting a deep knowledge of the system (just that for their selfish and criminal intents). So also did the creators of the internet and microsoft, server replication and cloud computing, etc. A lot of things we do as programmers can be called hacking. For example if you are a web programmer/developer/designer, you would know that IE is a nightmare. However, there are things we do that leverage on great understanding of the browser so that we can stretch of enhance its abilities. A very common IE hack is the conditional comment: <!--[if IE]> CssCode<![endif]-->. For javascript, when you visit a page, clear the address bar and enter this code: javascript:document.body.contentEditable='true'; document.designMode='on'; void 0 You will be able to edit the page (without saving though). You can't just say hacking means breaking in to a computer, its just like saying anybody that has a gun is an armed robber |
Programming › Re: New Programming Challenge by tundebabzy(op): 9:06am On Jul 02, 2011 |
|
Programming › Re: Can You Or Do You Know Someone That Can Copycat 2go Java Chatting Software. by tundebabzy: 4:21pm On Jun 26, 2011 |
2go source code is on my laptop too. What do you want? |
Webmasters › Re: Hacking Challenge, Real Site. Come In. by tundebabzy: 4:03pm On Jun 26, 2011 |
*dhtml: To encourage me and dual core to crack any code, please add a babe reward to the post. . . *yimu* |
Webmasters › Re: Hacking Challenge, Real Site. Come In. by tundebabzy: 2:23am On Jun 26, 2011 |
I couldn't sleep so I just had to solve the challenge.>>>Now I can sleep. Hope I wake in time for church
|
Webmasters › Re: Hacking Challenge, Real Site. Come In. by tundebabzy: 1:26am On Jun 26, 2011 |
Just finished some maintenance work on my site and i'm seeing this at 1:25am. i'll be back tomorrow hopefully with my screenshot |
Literature › Re: Harry Potter Fans: New Harry Potter: by tundebabzy(op): 1:22am On Jun 26, 2011 |
Well, I didn't mean that literally. Pottermore allows you to be a part of the harry potter world, get recruited into Hogwarths and more. By saying the story continues, I meant that Harry Potter hasn't gone into the annals of history permanently, |
Literature › Harry Potter Fans: New Harry Potter: by tundebabzy(op): 11:42am On Jun 24, 2011 |
|
Programming › Re: New Programming Challenge by tundebabzy(op): 9:03pm On Jun 20, 2011 |
Nairaland geeks, abeg show yaself na?? |
|