ruby solution. Uses [] not () as per rule #1.