Put your programming skills to the test
coderbyte.com
coderbyte.com
x = [1, 5, 3, 2, 6, 4]
x.sort()
print x
Output: [1, 3, 2, 4, 5, 6]
Not to mention the incomplete standard library. I'm not sure what is the interpreter they're using but it's actually not that hard to sandbox the CPython one and disable certain functions/modules if necessary. function jsChallenge() {
return 1;
return 2;
return 3;
}
Returns 3 def pyChallenge():
print sum(s for s in range(1000) if s % 7 != 0 and s % 5 != 0)
pyChallenge()
Produces a TypeError, and using xrange produces a NameError (Python 3?). I have no idea what they're trying, but it doesn't work. NameError: name 'reduce' is not definedI'm not sure what it is, but I know I don't like "guess which subset of the language you get" being harder than actually solving the algorithms challenges.
It's a cool concept.
I also found that I like sites that don't focus on rankings so much. It's better if to achieve a level you get a certain number of points. When you have rankings, if a new person joins your site it looks like a daunting task to get to the top.
Also, I would include forums for discussing solutions after you've solved it or attempted a problem a certain number of times. Maybe let people see the solution forum and 'solve' the problem, but they only get 1 point for that. It can be frustrating to be stuck on a hard problem for someone trying to learn. Maybe it'd be cool if you let people ask questions about problems and other users could get points for answering questions, while making sure not to give away too much.
Some functions are missing from Python, and being able to use the standard lib would be nice.
function guestChallenge() {
// code goes here
var num = 0;
for (var i = 1; i< 1001; i++) {
if (i.toSring(10).match(/7/));
else num+=i;
}
return num;
}
Edit: I really should have added more context! The challenge was:Using the JavaScript language, have the function guestChallenge() add up all of the numbers from 1 to 1000. But everytime a number that contains a 7 is reached, don't add that number to the others (ie. exclude 7, 17, 370, etc). Do not put any code outside of the function and use the return keyword to return your answer from within the function.
And my program didn't generate any output at all, which leads me to believe I made a syntax error as opposed to just a logic error.
Edit again: Yes. I just had to fix my typing error ("toSring"), and then it passed. Thanks, guys!
The front page challenges asked for the sum of the integers from 1 to 1000, excluding those divisible by 5 or 7. Here was my sort of smart-ass answer:
function jsChallenge() {
var num = 1000;
var t = num;
var sum = t*(t+1)/2;
t = Math.floor(num/5);
sum -= 5*t*(t+1)/2;
t = Math.floor(num/7);
sum -= 7*t*(t+1)/2;
t = Math.floor(num/35);
sum += 35*t*(t+1)/2;
return sum;
}The first guest challenge asks for the sum of the integers from 1 to 1000, excluding those that contain the digit 7.
function jsChallenge() {
function sum(n) {
var k = Math.floor(1000 / n);
return n * k * (k + 1) / 2;
};
return sum(1) - sum(5) - sum(7) + sum(35);
}I'm surely not the only one to do this sort of thing. Maybe there should be some kind of feedback instead of nothing happening when I click the run button.
To others, the demo question on the home page is a divisible by 5 or 7 problem. This is one of the guest challenges and is that the number contains the digit '7'.
Using the Python language, have the function pyChallenge() add up all of the numbers from 1 to 1000. But every time a number appears that is divisible by 5 or 7, disregard it and do not add that number to the others (ie. disregard 7, 10, 15, 21, etc). Do not put any code outside of the function and use the print keyword to return your answer from within the function.
def pyChallenge():
sum = (1000 * (1000 + 1)) / 2
for i in range(5, 1001, 5):
sum -= i
for i in range(7, 1001, 7):
sum -= i
for i in range(35, 1001, 35):
sum += i
print sum
#As opposed to:
#sum = 0
#for i in range(1, 1000):
# if i % 5 and i % 7:
# sum += i
#print sum
# this call is needed to test your function
pyChallenge() def pyChallenge():
print sum([el for el in range(1001) if not((el%5==0) or el%7==0))])
# this call is needed to test your function
pyChallenge()I know I selected python because it let me test my code by running it both before and after I submitted.
Anyway it's still really fun - keep up the good work!
Yet, UI is ridiculous. Logging in utilises pattern, I've never seen before (just displaying the same login form with a tiny "Thanks for logging in" message below).
If you use javascript so thoroughly, try to implement HTML5 History API (stay clear of hashbangs, please). A few times I clicked "back" and went back 5 steps.
Some of backend glitches, probably, can be ignored because of "unexpected" load, right? :)
Having said all that, it's good that after Bespin and all-favorite CodeAcademy, programming challange sites get modern touch.
One thing I would recommend is making sure the problem descriptions are extremely clear, clarifying bounds, etc. For instance, "Using the JavaScript language, have the function jsChallenge() add up all of the numbers from 1 to 1000." This should probably read "... numbers from 0 to 1000 exclusive" or something similar. Looking at problems from programming competitions such as ACM ICPC would provide really great reference material, at least in terms of how to describe a problem.
For super quick learning, it sure would be nice to see how others solved the same challenge. Just a few suggestions for links in the "Your code was correct, great job!" box:
- last 5 correct solutions
- most common solution
- solution in least lines of code
- solution in least bytes of code
- solution presented by <person requested>
and if you really wanted to get clever: - most unique (by some definition) correct solution
- most elegant (by some definition) correct solution
- you should use <this> instead of <that> and <why>