CodingBat code practice

CodingBat is a free site of live coding problems to build coding skill in Java, and now in Python (example problem), created by Nick Parlante who is computer science lecturer at Stanford. The coding problems give immediate feedback, so it's an opportunity to practice and solidify understanding of the concepts. The problems could be used as homework, or for self-study practice, or in a lab, or as live lecture examples. The problems, all listed off the CodingBat home, have low overhead: short problem statements (like an exam) and immediate feedback in the browser. The idea for CodingBat came from my experience teaching CS at Stanford combined with seeing how student's used unit-tests in more advanced courses
http://codingbat.com/

Hozzászólások

Találtam egy hibás megoldást.

Java > Warmup-1 > front3

Given a string, we'll say that the front is the first 3 chars of the string. If the string length is less than 3, the front is whatever is there. Return a new string which is 3 copies of the front.

Viszont szerinte ez a kód hibás:


public String front3(String str) {
  String front = (str.length()<3)? "whatever is there" : str.substring(0,3);
  return front+front+front;
}

… vajon mit csinálok rosszul? ☺

int getRandomNumber() { return 4; }  // ← aláírás
//szabályos kockadobással választva. garantáltan véletlenszerű.  xkcd

Mostanában elég menő lett ilyen „tanítsunk meg mindenkit programozni” oldalakat csinálni...
--
blogom