Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 04, 2016, 06:24:13 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Code Koans  (Read 5067 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Code Koans
« on: December 03, 2011, 01:53:44 AM »
Summary List




Trying out the Ruby Koans:

  http://rubykoans.com/

Short video mentioning them and similar approaches for Clojure, Scala, and JavaScript:

  http://www.youtube.com/watch?v=mG6NsCIRKAk

Some bits from the video to get a sense of the flow:

1. Download, extract, run tests (assuming Ruby is installed):
1. download-unzip-run-tests.pngCode Koans

2. Look at test results:
2. first-results.pngCode Koans

3. Examine relevant code:
3. examine-code.pngCode Koans

4. Change code appropriately (trying things in irb and reading docs first if necessary):
4. change-code.pngCode Koans

5. Run tests again and look at results:
5. run-test-again.pngCode Koans

6. Repeat...

Link from the video with some details of the four:

  https://bit.ly/code_koans
« Last Edit: January 12, 2012, 06:12:06 AM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #1 on: December 04, 2011, 12:21:00 AM »
Found some Python ones.

There's a version for Python 2.x (python 2 folder) and one for Python 3.x (python 3 folder).

I used the "get source" near the top right of the aforementioned page to get an archive of the relevant files.

about color
Seems to work fine on Windows :)

« Last Edit: December 04, 2011, 01:38:43 AM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #2 on: December 07, 2011, 04:08:33 PM »
Color output for the locally installed (2010-12-23) Ruby Koans seems to work now.  The following steps were performed toward this end:

1. Install the win32console gem (adapted instructions from: https://github.com/o...wiki/development-kit):

gem install win32console --platform=ruby

2. Apply the following changes to edgecase.rb:

  https://github.com/edgecase/ruby_koans/commit/a53c815da0af5974cd5bcd8bb38bc3f66742715b

Attached is an updated version of edgecase.rb.

* edgecase.rb.zip (3.86 kB - downloaded 107 times.)

Ruby Version
This was all for a Ruby (1.9.3) .7z-based installation + DevKit obtained via:

  http://rubyinstaller.org/downloads/


ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #3 on: December 09, 2011, 03:19:52 AM »
Somehow I'm finding the colors too dark on my screen and the line numbers hard to see.  Didn't figure out anything for the former point, but made a quick hack to make (some?) line numbers stand out.

Attached are a patch and patched file including the earlier win32console color-enabling along with  "line numbers standing out" behavior.  The rest of a colored line with a line number turns white, but that doesn't seem to be a problem visually to me.

* koans-color-and-line-number-color.zip (0.77 kB - downloaded 104 times.)
* edgecase.zip (3.98 kB - downloaded 116 times.)

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #4 on: December 09, 2011, 04:18:06 AM »
Found some Python ones.

There's a version for Python 2.x (python 2 folder) and one for Python 3.x (python 3 folder).

I used the "get source" near the top right of the aforementioned page to get an archive of the relevant files.
Thanks! I've been playing with this and finding it amusing :)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #5 on: December 09, 2011, 04:32:37 AM »
:Thmbsup:

Out of curiosity, are you trying the 2.x ones or the 3.x ones (or both)?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #6 on: December 09, 2011, 08:50:14 AM »
2.x, it's the one I had already installed in the computer. But I might try the 3.x later :) (along with other languages ;) )

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #7 on: December 30, 2011, 02:55:23 AM »
Thanks for the info :)

I'm mostly through the Ruby ones -- though got diverted for quite some time trying to understand one of the koans [1]. Ended up opening a can of worms (or swallowing a red pill depending on your perspective) which seems better to have done sooner than later.

May be the Python ones will also end up pointing out huge unknown areas too.

Which set to try next...


[1]
diversion was about...
Meta-programming in Ruby


ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #8 on: January 06, 2012, 06:36:20 PM »
There appear to be more than one JavaScript set:


ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #9 on: January 07, 2012, 08:50:41 PM »
Still working on the JavaScript ones, but found a CoffeeScript set by Nigel Runnels-Moss.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #10 on: January 07, 2012, 08:59:36 PM »
Have had success running the JavaScript set by David Laing on an Android tablet.  The editing is a bit painful at times (using the built-in editor that comes with ES File Explorer), but at least it is doable.  I've tried with Opera Mobile so far.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #11 on: January 08, 2012, 01:03:40 AM »
On a pc, using an interactive shell / repl seems to be helpful for trying things out -- for JavaScript, I'm using the 'node' command from node.js with no arguments and this seems usable.

Haven't tried out anything similar for Android yet -- may be SL4A is worth considering...
« Last Edit: January 10, 2012, 08:05:13 PM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #12 on: January 10, 2012, 08:08:43 PM »
Made it through David Laing's set -- punted the extra credit section for the moment.  A side effect of doing this set was that got some experience with Underscore.js and Jasmine.

Also, the coding style of the tests seems closer to that of Crockford / jslint than what I'm seeing in so far in Liam McLennan's set.
« Last Edit: January 12, 2012, 12:47:11 AM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: Code Koans
« Reply #13 on: January 11, 2012, 08:52:01 PM »
Liam McLennan's set appears to cover more basic ground and doesn't appear to be influenced much by jslint-ish concerns (e.g. placement of 'var', use of ++, etc.).  On a minor note, I noticed some typos and spacing felt odd at times.

It uses QUnit, so one can get some experience with that.

Also got quite stuck on the first part of the 'hasOwnProperty' test -- and looks like someone else did too:

  http://stackoverflow.com/questions/6807005/javascript-koans-cannot-solve-one-test

As of this writing, the answer at StackOverflow doesn't work here, FWIW.

For this particular item, node.js' repl was not helpful -- it doesn't provide a browser context.  A repl in a browser may not have helped either, as arrays had been modified by the test set specifically for testing...

details...
SO has 'fruits.prototype' for the third element of keys -- here what worked was 'equalTo'

« Last Edit: January 12, 2012, 12:46:33 AM by ewemoa »