DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Code Koans  (Read 15,436 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Code Koans
« on: December 03, 2011, 07:53 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.png

2. Look at test results:
2. first-results.png

3. Examine relevant code:
3. examine-code.png

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

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

6. Repeat...

Link from the video with some details of the four:

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

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #1 on: December 04, 2011, 06:21 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, 07:38 AM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #2 on: December 07, 2011, 10:08 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/oneclick/rubyinstaller/wiki/development-kit):

Code
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.9 KB)

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,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #3 on: December 09, 2011, 09:19 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 (791 B)
edgecase.zip (4.0 KB)

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Code Koans
« Reply #4 on: December 09, 2011, 10:18 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,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #5 on: December 09, 2011, 10:32 AM »
:Thmbsup:

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

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Code Koans
« Reply #6 on: December 09, 2011, 02:50 PM »
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,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #7 on: December 30, 2011, 08:55 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,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #8 on: January 07, 2012, 12:36 AM »
There appear to be more than one JavaScript set:

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #9 on: January 08, 2012, 02:50 AM »
Still working on the JavaScript ones, but found a CoffeeScript set by Nigel Runnels-Moss.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #10 on: January 08, 2012, 02:59 AM »
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,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #11 on: January 08, 2012, 07:03 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 11, 2012, 02:05 AM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #12 on: January 11, 2012, 02:08 AM »
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, 06:47 AM by ewemoa »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Code Koans
« Reply #13 on: January 12, 2012, 02:52 AM »
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, 06:46 AM by ewemoa »

Original address: https://www.donationcoder.com/forum/index.php?topic=29030.0