Wednesday, May 21, 2014

Reeborg programming challenges - Challenge #1

Can you have Reeborg do multiplication without using numerical variables?

Reeborg must show that it can multiply two numbers by taking a number N tokens located at x=1 and  y=Y, and leave a single token at row y=1 and x = N*Y.  For example, here's a starting position (image taken from RUR-PLE, so that it looks a bit different from the web version)
the final position must be
where a single token must be deposited.

So, without using numerical variables, and using only a single instruction per line (so no use of semi-colon, or having a colon followed by a statement), how short can a solution to this problem be?  Here's an example of a solution that is NOT allowed under the above rules:
think(0)
select_challenge("mul5x1")
y = 1      # numerical variables not allowed
tokens = 0;turn_left()  # use of ; is not allowed
def turn_around():
    turn_left()
    turn_left()
while not token_here():  
    move()
    y += 1  # not allowed
while token_here():
    take()
    tokens += 1  # not allowed
turn_around()

while front_is_clear():  move()  # not allowed, statement after colon

turn_left()
repeat(move, y*tokens-1)  # not allowed, multiplication
put()

The solution must work for 5 different challenges (mul5x1, mul1x5, mul5x5, mul4x3, mul3x2) - or any other such challenges for which I could create a world. Excluding the line with think(0), which makes Reeborg move as quickly as possible, and the line select_challenge(...), can you write a solution shorter than 29 lines?  Solutions can be attempted at Reeborg's World. You may want to click on the help button to see a brief summary of all known instructions.




Le monde de Reeborg: finalement en français!

J'ai finalement complété la traduction de la nouvelle version du monde de Reeborg en français. Les tutoriels pour débutant, que ce soit pour Python ou pour Javascript ne sont cependant pas encore traduits.

Si la version française vous intéresse, svp contactez-moi par courriel (ou laissez un commentaire sur ce billet) pour me le laisser savoir et que je puisse mieux juger du besoin de traduction des tutoriels.

Thursday, May 15, 2014

Eating your own dog food

When I created rur-ple, my intention was to use it to teach my pre-teens computer programming.  When it was working reasonably well, and after having written a few lessons, I showed it to my daughter who quickly went through the material I had prepared and concluded that it was too easy/boring.  She essentially decided then that programming was not for her.

Fast forward 10 years.  She had to do some programming as part of her university program and found out that she really enjoyed it.  She is currently more than 1000 km away, working in a lab where she has to program in Python, which she is essentially just learning.  She had a question for me, emailed me some code when I got the idea of using Reeborg's world's editor and the embedded TogetherJS from Mozilla so that we could share a screen, while talking using Skype.  

It worked very well. :-)   However, I found that, while the fixed-size editor was big enough for the tutorials I wrote, it was too limiting when trying to work collaboratively on "real life" code.  The same could be said for the output area ("Reeborg's Diary"). Nothing like "eating your own dog food" to find its limitations.    So, after a couple of hours of tinkering with javascript/jquery/css, I finally got a reasonably working setup for remote collaboration/help on Python 3 code (using Brython) or Javascript or CoffeeScript or .... (more languages to come eventually).


The only limitation that we found is having the TogetherJS chat window in a fixed position. If it could easily be moved (on a per-user basis), it would make it even more useful.

Tuesday, May 13, 2014

Python tutorial for beginners.

The first draft of my Python tutorial for beginners is now live.  The previous link is for the tutorials; the actual code needs to be entered in Reeborg's World.  There is also a Javascript version of the tutorial.