by kyro · 16y ago · 0 comments
I am always so surprised when I hear that, and have a difficult time believing that's true. With only an extremely beginner's level understanding of Python, I can solve FizzBuzz. Can I get a dev job?
I didn't know what fizzbuzz is until I read about it on wikipedia. But I frequently run into "web developers" that don't how sessions work or how cookies work and don't understand what CSS does. But i figured it was just these guys who give programmers a bad name. I had no idea it was really that bad and extends to the basics of programming.
I know modulus isn't necessary, but I can see someone not doing the problem if the solution they are turning in is in a less elegant way.
If you prefer, you can substitute a similar problem which doesn't require even fourth grade math. Here's one: write a program which calculates the sum of all numbers between 1 and 1,000 whose digits sum up to 7. Or write a program which takes this post as input and tells me what the 3rd most common letter used was.
from collections import defaultdict
from string import ascii_letters
d= collections.defaultdict(int)
for letter in post:
d[letter] += 1
print [letter for letter in sorted(d, key=d.get, reverse=True) if letter in ascii_letters][2]
Any comments on improvement for readability or conciseness?My Python answer:
sum(x for x in xrange(2, 1000) if sum(int(y) for y in str(x)) == 7)
# 9324
Anyone have improvements on that?(I used the range (1, 1000) as opposed to [1, 1000], but it doesn't make a difference since the edge values don't have digits that sum to 7.)
I'm going for 'a'.
And, according to http://en.wikipedia.org/wiki/File:English_letter_frequency_(... (via http://en.wikipedia.org/wiki/Letter_frequency) your four most frequently used letters match the table for English.
Tested in Python 2.7:
s = "your text here"
import string
d = {}
for i in list(s.lower()):
if i in string.letters:
d[i] = d.setdefault(i, 0) + 1
print sorted(d.keys(), cmp = lambda x, y : cmp(d[x], d[y]), reverse = True)[2]
Edit: See my later response for something using the 'collections' module.And no, I don't feel sorry for people like this. Despite their glaring incompetence they still manage to snow people into hiring them. Some of them easily make $500,000/year and up if they remora themselves to the underbelly of a large company and emit horrible VB code.
edit: definitely broad strokes