Testing Programmers: Puzzles Or Mini Web-Apps?

32 comments
As you know, I like to sponsor web application programming contests, for example, thisthis, and this

In a recent conversation with an Android programmer, he asked why I don't follow Google's practice of asking people to solve puzzles. According to him, people who can solve programming puzzles can definitely build webapps, but many people who build webapps can't solve programming puzzles. I asked why these programming puzzle solving geniuses can't learn Python to write simple webapps for cash, and I think he said it's because basic webapps are not cool enough to interest them.

What do you think? If interviewing a programmer for a role on your team, would you ask the programmer to solve programming puzzles or would you ask them to develop something simple but complete like a mini webapp? Which approach will result in the best, most productive hire? 

Mini Web Application Coding Challenge For Programmers

17 comments
You've been hired to teach Computer Appreciation at a local Secondary school for one term. During that term, you're expected to give the students 2 tests (15 marks each), one practical project(10 marks) and 1 exam (100 marks to be scaled down to 60 marks).

Write a secure single user mini web application that you can use to enter each student's name and raw scores, calculate each student's total score for the term (a percentage), determine the position of each student in the class, and calculate the average score for males & females in the class.

  • Use mercurial, git or subversion for source control and post your solution on git/bitbucket/google-code!!
  • Write the application in any programming language or web framework of your choice (except maybe PHP?)

The Social Network Chicken And Egg Problem

38 comments
I got this interesting question in my inbox recently:
Hey Seun,
You don't know me. I'm just a fan of yours. I'd like to know how you solved the "chicken and egg" problem and succeed with nairaland. Networks like nairaland, fb, twitter are only valuable when there's a community on it. Therefore nobody wants to join, unless there are already a bunch of users. So how did you gain traction?
 So, you want to start a poultry farm.  You need eggs to make chickens, but you need chickens to lay eggs, so what do you do?  How do you solve this problem?  Simple:
  1. Buy lots of chickens. The chickens will lay eggs, which will develop into new chickens.
  2. Buy lot of fertilized eggs and incubate them. They will develop into egg-laying chickens.
To get a social network going, you just have to bribe or beg people to join your social network until it's big enough to sustain itself. If you're evil, forcing or tricking them to join also works:
  • In 'The Social Network' Mark Zuckerberg bootstrapped a social network by hacking into student records and creating accounts for students without their consent, effectively forcing them to join.
  • Some dating sites solve the chicken and egg problem by paying a bunch of beautiful female models to join the site and participate.The models attract a lot men to join the site (a form of trickery really), and this attracts more women.
  • With Twitter and Quora, employees of the company were the first to start using the sites heavily, then their friends and family, then attention seekers, geeks and celebrities, and finally regular people.  In effect, Twitter and Quora employees were initially paid not just to develop the respective sites but to use them and post on them regularly.
Until your social network takes off, you'll just have to bribe or beg people to join and participate. I did that.

Solutions To India's Girl Baby Murder Problem

13 comments
In response to Umari Ayim's post about the practice of female-infanticide in India (poor people killing their baby girls because they can't afford to raise them and pay their dowries when they are of age), I suggested two ways to solve the problem:

1) A dirt-cheap and speedy adoption process, open to locals and foreigners of any religion or orientation. There are many people in the world who would give anything to have a baby girl. The adoption process should probably include some monetary compensation for the biological parents.

2) Legalization of early stage abortion (up to 3 months or so) for any reason or purpose whatsoever, such as the fetus being the wrong sex. Abortion is awful, but it's not as awful as parents killing their own children or abandoning them, or abusing them. In other words, legalize the lesser evil to prevent a more terrible one.

Don't Use Quota Systems To Enforce Equality

5 comments
In response to this bit of news:
The Central Bank of Nigeria on Tuesday said it was currently working with banks to ensure that a certain percentage of the position of senior management and board members were reserved for women.
I wrote this:
I think it's wrong to use a quota system to try to enforce equality in management or any other field.

A quota system might almost make sense if we assume that the only reason we don't see an equal number of women in senior management is because evil men refuse to promote competent female managers, but that's not true. The fact is that women don't aspire for leadership the way men do, because they think that is not their role in life.  Most women think womanhood is about looking good and making babies so they tend to sacrifice their careers for family life.  If a man gets a good job in a different city, his wife will resign from her job to follow him. If a woman gets the same opportunity, her husband will not resign to support her. Then there's maternity leave. Little things like that add up over time.

Even when a woman is trying to move ahead in the corporate world, other women will try to pull her back by branding her as a NaughtyWoman or spreading rumors that she must have slept with the boss. The few women trying to get ahead tend to rely more on their looks and the cuteness factor instead of concentrating on substance and performance, and it works for them to a point, but not to the very top. As a result, in banking and many other industrial sectors of Nigeria, the best candidates for top management roles are unlikely to be women.

This is not to say women don't have the ability to be great leaders. The problem is that they are not encouraged to develop their leadership potentials, so most of them don't do so.  As a result, a quota system mandating that a particular percentage of senior managers must be women is going to result in a lower quality of leadership.  It's not fair that women are not allowed to develop their potentials, but it's also not fair to shareholders if you prevent banks from appointing the very best senior managers they can find regardless of whether such candidates are men or women. An insufficiently competent senior manager can ruin any company, so you want the very best, male or female.

Such "pro-women" policies will also encourage female managers aspiring for top positions to relax.  If I know I'm the only female manager in a company and the company is forced to appoint 3 senior female managers by law, then why should I improve my performance? If a woman is guaranteed a slot at the very top by virtue of her gender then why should she strive to be better than men? Currently, women at the top are respected because we know they must be very good to have gotten there, but once such policies are in place, that will no longer be the case. Do we want that?

I would like to see more women in senior management, but the best way to achieve that is by encouraging women to work harder and take their careers more seriously. It's by commending women more for working hard and being smart than for looking good. It's by not telling women that they are supposed to be "submissive".  It's by helping your wife at home or hiring domestic helpers so she can work harder at her job. It's by celebrating women who are good at what they do for being good at what they do, and not for their beauty. By treating the disease and not the symptom.
From Re: CBN To Reserve Bank Management & Board Seats For Women

Privatize Public Schools And Distribute Their Shares To The Masses

The Best Way To Privatize Public Schools In Nigeria
In the spirit of democracy, capitalism, and reducing the cost of government

I believe a fully privatized educational system will be best, especially in a country like Nigeria in which the government is both poor and corrupt, and therefore incapable of funding or managing public schools effectively. Critics of privatization have pointed out that when government institutions are privatized, they end up being (1) controlled by the rich friends of the government and (2) unaffordable to the common man. 

If Nigerian public schools are all privatized, they could end up being controlled by people who have no interest in education and just happen to be rich, well connected, and willing to bribe. If all schools in Nigeria are private, we could end up with a country in which only rich can afford education. And that won't be ok because we all know what happens when the masses are not educated: you have a high crime rate, religious crises, etc.

However, our public schools are in a deplorable state. A few public schools are doing relatively well, but they are not really public schools anymore, because they charge all sorts of fees. We might as well privatize them too. We could try to convince the government to pump more tax-money into the worst public schools, but that would be like pouring more water into a basket. I believe the government should be more involved in setting educational standards, making sure WAEC, NECO, and JAMB exams are free of cheating, and properly marked, etc. (instead of running schools).

However, instead of simply selling public schools to the highest bidder, I believe every public school should be turned into a limited liability company, and 1 share of that company should be given (not sold) to every adult resident of the LGA the school resides in, and every current employee of the school.

The current principal of each school should be made the CEO, and the head teachers and current PTA officials made directors of each school. This will turn public schools into for-profit organizations that have a strong incentive to keep costs low, improve educational standards and find ways to make more money with the schools' land and resources.  Public schools will no longer be an unproductive drain on our national resources.

This approach will put the schools in the hands of communities instead of just the governors' crony capitalist friends. The sense of ownership the community feels about the schools, as a result of their actual ownership, will encourage every individuals to help their schools in various ways, and to fight anyone that tries to damage the schools. If the officials the schools don't perform, they will be voted out in shareholder meetings.

Since the shares will be owned by both rich people and poor people in the community, the school is likely to pursue policies that make it possible for children of the poor to afford the privatized schools, such as academic scholarships and multiple tiers of service so rich students subsidize poor students. At the same time, they will avoid policies that can make the school go bankrupt (otherwise, the poor shareholders will get no dividends!)

There will be a healthy balance of empathy, social values, pragmatism, and capitalistic creativity and efficiency. It shouldn't be hard to try it out with a single public school to see how it turns out. We should start with schools that are currently in a very bad state, such as this one, and this one.

What do you think about school privatization in general, and this approach specifically? What are some of the challenges you envisage? Do you have any suggestions about how to improve this, or reasons why it may work or not work?
Source: Privatize Public Schools And Distribute Their Shares To The Masses

Smallest And Largest Floating Point Values In Python

6 comments
In my production code, I have a function that calculates a/(a+b). That function threw a ZeroDivisionError at me this afternoon, so I decided to change the equation to a/(a+b+sys.minfloat), because I felt that was more elegant than writing a conditional function to check if (a + b) == 0.

Turns out there is no 'minfloat' in the sys module, so I decided to write a function to calculate the smallest float myself.
>>> def minfloat(guess):
while(guess * 0.5 != 0):
guess = guess * 0.5
return guess

>>> minfloat(+1.0) # minimum positive value of a float
4.9406564584124654e-324

>>> minfloat(-1.0) # minimum negative value of a float
-4.9406564584124654e-324


But I couldn't stop there. Now I had to write a function to calculate the largest possible floating point value in Python, just for kicks:
>>> def maxfloat(guess = 1.0):
while(guess * 2 != guess):
guess = guess * 2
return guess

>>> maxfloat(+1.0) # maximum positive value of a float
inf

>>> maxfloat(-1.0) # maximum negative value of a float
-inf


This is interesting. Let's find out more about this "inf" value:
>>> inf

Traceback (most recent call last):
File "", line 1, in
inf
NameError: name 'inf' is not defined
>>> float("inf")
inf

>>> inf = maxfloat()

>>> inf + inf
inf

>>> inf - inf
nan

>>> 1 / inf
0.0

>>> 1/(-inf)
-0.0


Finally, check the relationship between minfloat and maxfloat:
>>> 1 / minfloat(1.0)
inf
>>> 1 / minfloat(-1.0)
-inf