From stuart at gathman.org Thu Mar 2 00:08:40 2006 From: stuart at gathman.org (Stuart D. Gathman) Date: Thu, 2 Mar 2006 00:08:40 -0500 (EST) Subject: [Verba] Meeting summary Message-ID: Rebecca and Jillian worked some more on the robots game in python. (Attached.) You can now move around a black dot on the screen with the keyboard! While considering edge mappings, we very briefly discussed "topology" - the properties of shape that are invariant under stretching. The wrap around edge mapping we chose is topologically a torus (donut shape). We will have to investigate that more, because it is closely related to - you guessed it - group theory. Speaking of which, I mentioned using group theory to chose a spouse. :-) (Disclaimer - the assumptions in this model are vastly over simplified and are for instructional purposed only. In particular, I would question the assumption that candidates can be rank ordered. And, of course, the goal of the "courtship" movement is by careful preparation to have only one proposal which you accept.) It works like this (taken from "The Equation that Couldn't be Solved"): Assume you will get 4 marriage proposals, and that if you could consider all the proposals at once, you could rank them from worst to best. However, you get only one proposal at a time in random order. And you must accept or reject each in turn. Your strategy is to reject k - 1 proposals, then accept the first proposal that is better than any previous proposal. What is the optimal value of k? There are 24 permutations of the rank order in which your proposals may come: 1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321 For k == 1, you accept the first proposal. 6 of the 24 permutations have the best proposal come first. So your chances are 6/24 or 1 in 4 of getting the best match. For k == 2, you get the best match for cases 1423, 1432, 2143, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421. That makes your chances of getting the best 11/24. For k == 3, your chances are 10/24. For k == 4, you are back down to 6/24. So, for 4 expected proposals, the optimum strategy is to turn down the first, then accept the first that is better than any previous proposal. For 5 to 8 expected proposals, the k == 3 is optimum (turn down the first 2, the accept the first that is better than any previous). For a large number, 'n', of proposals, k == 1 / e is optimum. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. -------------- next part -------------- from livewires import * def place_player(): global player_x,player_y player_x = random_between(0,63) player_y = random_between(0,47) return circle(player_x*10+5, 10*player_y+5, 5, filled=True) def move_by(x,y): global player_x,player_y player_x += x if player_x < 0: player_x = 63 if player_x > 63: player_x = 0 player_y += y if player_y < 0: player_y = 47 if player_y > 47: player_y = 0 move_to (player, player_x * 10 + 5, player_y * 10 + 5) def move_player(k): if k == "1": move_by(-1,-1) if k == '2': move_by(0,-1) if k == '3': move_by(1,-1) if k == '4': move_by(-1,0) if k == '5': move_by(0,0) if k == '6': move_by(1,0) if k == '7': move_by(-1,1) if k == '8': move_by(0,1) if k == '9': move_by(1,1) if k == 'q': finished = True #teleport() begin_graphics() allow_moveables() player = place_player() finished = False while not finished: for k in keys_pressed(): move_player(k) sleep(0.25) end_graphics() From stuart at gathman.org Fri Mar 17 18:17:34 2006 From: stuart at gathman.org (Stuart D. Gathman) Date: Fri, 17 Mar 2006 18:17:34 -0500 (EST) Subject: [Verba] Meeting Summary Message-ID: Last week (I'm behind on summaries), we cut up paper to model the many ways of gluing together the edges of a screen (choices for what to do when reaching the edge of the screen in a 2D game). Most of the resulting 2D surfaces can be modeled with paper, but 2, the Klein bottle and projective plane require 4 dimensions. We then added a place_robot function. This week, I went to the Chenettes, and Jilian joined via AIM. Rebecca and I made the place_robot function actually work, while Jilian figured out how to CD her Windows Command prompt to the proper directory and run a python script. Then I played some hymns in Jazz style for Rebecca, who very sweetly professed to like them. Let me remind everyone that our excursions into group theory are not directly related to programming, but were needed to understand a problem domain of interest (solving Rubik's cube). But, understanding it will help you excel at Math - especially abstract algebra and modern physics. To build programming skills, you need to keep doing it - just like learning an instrument or sport. Try to come up with problems to solve using your skills, and solve them. Here is a simple problem related to group theory. Remember that any group (including Rubik's cube) is isomorphic to a permutation group. A basic operation needed for dealing with permutation groups is to list their members. We introduced Python "generators" for the deal_position function. This assignment asks you to create a generator that lists all the permutations of a sequence. It should be written as a generator. For instance, def permute(s): ... blah blah ... ... yield something ... blah print permute([1,2,3]) should output: [1,2,3] [1,3,2] [2,1,3] [2,3,1] [3,1,2] [3,2,1] or the same permutations in any order. Do not assume that the members of the permutation group are numbers. They can be any Python object. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From stuart at gathman.org Mon Mar 20 18:09:02 2006 From: stuart at gathman.org (Stuart D. Gathman) Date: Mon, 20 Mar 2006 18:09:02 -0500 (EST) Subject: [Verba] Rubik's cube robot Message-ID: Taylor wanted some C source code to look at for solving the cube (skipping the whole group theory thing). Instead of just mailing the code, I thought I'd show y'all a Lego Mindstorms robot that solves cubes. http://jpbrown.i8.com/cubesolver.html The link to the C code is at the bottom under part 6. It would sure be cool for the computer club to have a robotics kit (Lego or other). -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From stuart at gathman.org Wed Mar 22 19:10:56 2006 From: stuart at gathman.org (Stuart D. Gathman) Date: Wed, 22 Mar 2006 19:10:56 -0500 (EST) Subject: [Verba] Last Meeting Summary :-( Message-ID: Copyright Law Somehow we started out with a discussion of Copyright law and fair use. No, it is not OK to give copies of CDs to your friends without permission. Yes, it is OK to make copies for your own use, including copying to different formats for Car, Ipod, etc. Internet friendly publishers often due give permission for limited copies. I showed http://magnatune.com as an example. MP3s from that site be copied according to a Creative Commons (http://creativecommons.org) license: http://magnatune.com/info/openmusic Mrs. Brown - I happened to have a copy of Magdalena with me: http://magnatune.com/artists/albums/joglaresa-magdalena/ These are Medieval hymns in Latin (a few in old French). Good practice for Latin students. You (and students) can play and download the MP3s free of charge, but the "non-commercial" clause on the CC license I think means you need to buy a license for the school to play the songs for the students as part of school: https://magnatune.com/artists/license/?artist=Joglaresa&album=Magdalena&genre=World We then discussed the DMCA and the case of "DVD Jon": http://en.wikipedia.org/wiki/Jon_Johansen who didn't actually spend time in Jail as I alleged (although someone else did for similar charges). Permutations No one else had come up with a permutations program, so we reviewed mine. (Attached). Intelligent Design Somehow, permutations led to a discussion of the difference between complexity and "specified" complexity, and then to the philosophical basis of materialism. Summer School Reading I loaned "Adventures in Group Theory" to Jillian, and Rebecca currently has "The Equation that Couldn't be Solved". My new copy of "G?del, Escher, Bach" arrived a few minutes after I left for Ad Fontes :-( I am reserving it for Computer Club members. My old copy I already loaned out it turns out. GEB is directly related to computing - and should take precendence over the group theory books for learning programming. Group theory is a "problem domain" (as well as being interesting and several Club members being Rubik's Cube fanactics). Hands On A big road block for the club was learning to handle shell prompts / command prompts and basic system administration like creating directories / folders (and finding them again). My (probably ambition) recommendation is for students to spend their entire summer going dumpster diving for junk PCs, refurbishing them, and installing free/open software on them (e.g. Linux). They will become confidently familiar with BIOS settings, hardware diagnosis and repair, boot sectors, partitions, file systems, firewalls, etc. :-) I'll probably have to settle for something less ambitious, if anything - like maybe an old system lying around the house, or installing an extra disk drive for dual booting between Windows and Linux. On that note, Taylor has obtained an external 10G firewire disk drive for his Mac Mini. His project is to install PPC Linux on it. Way to go Taylor! (Here's hoping you don't accidentally wipe your OSX disk.) -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. -------------- next part -------------- def permute(s): if not s: yield s return if type(s) is str: for i,first in enumerate(s): for cc in permute(s[:i]+s[i+1:]): yield first + cc else: for i,first in enumerate(s): first = [first] for cc in permute(s[:i]+s[i+1:]): yield first + cc for x in permute('abc'): print x for x in permute([1,2,3]): print x From stuart at gathman.org Sat Mar 25 14:12:56 2006 From: stuart at gathman.org (Stuart D. Gathman) Date: Sat, 25 Mar 2006 14:12:56 -0500 (EST) Subject: [Verba] The Interconnectedness of all Things Message-ID: "And HE, [Christ], IS before all things and in and through Him the universe is a harmonious whole." Collossians 1:17 WEY Question 1 In our last meeting, we talked about how Materialism denies the reality of "meaning". We talked about the game of Boggle?, and the difference between complexity and specified complexity. Specified complexity means certain combinations are intelligently chosen beforehand. The word "intelligence" literally means "to choose between". I claimed that symbols have meaning when they are chosen by an intelligent person. In "G?del, Escher, Bach" on page 50, Hofstadter gives his definition of "meaning" - meaning is an isomorphism between symbols and some portion of "reality". Are these definitions of "meaning" the same, different, related? This guy just doesn't know when to quit ... Exercise 1 At the bottom of page 39, Hofstadter describes a genie with all the time in the world creating theorems in the MU system. Write a python program to output MU theorems using the method described. Besides time, what limits the number of theorems the program can output? Exercise 2 In the newpaper, there is a "Jumble" puzzle. Write a program that takes jumbled letters as input, and lists all permutations that are english words. "English word" is defined as any word occuring in the "Official Scrabble Players Dictionary" version 3. You can download this at: http://gathman.org/python/OSPD3.gz You will need some things we didn't mention in class. Use the Library Reference and Module Index at http://www.python.org/doc/ Hints: a) you will need the gzip module to unpack OSPD3.gz b) you will need to use File objects: http://docs.python.org/lib/bltin-file-objects.html Here is the output from my version: $ python2.4 jumble.py ~ terp PERT ~ alksf FLASK ~ an AN NA ~ I will share my solutions when you are ready. You can learn a lot from looking are python code from people all over the world: http://www.python.org/community/ Future Directions (Next year? Summer?) Python is a very high level imperative language. a) We can go low level and tackle assembler code and Knuth. A Linux or Mac system is required. Windows is too dangerous to play around with assembler (and you will learn basic precautions such as not testing your cool brand-new assembler program as root or even with your normal login). b) We can go non-imperative and tackle Prolog or Functional programming. c) We can go mid level and look at Forth or C. d) We can go really low level and look at logic gates and memory cells in various technologies from TinkerToys? to CMOS. e) We can go really hands on and buy a robotics kit to play with. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From stuart at gathman.org Sat Mar 25 17:31:37 2006 From: stuart at gathman.org (Stuart D. Gathman) Date: Sat, 25 Mar 2006 17:31:37 -0500 (EST) Subject: [Verba] Musical Offering Message-ID: It adds a lot to a reading of GEB to be able to hear the music: http://www.amazon.com/gp/product/B000050GK0/ -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial.