Please find below a choropleth map the population densities in the various London boroughs.
After wasting too much time colouring in maps using MS Paint, I thought there must be an easier way, so I had a go at drawing a stylised map of London borough using SVG.
Most of free svg maps online used paths to trace each borough, I wanted polygons so I had to draw it from scratch.
The population densities are calculated from wikipedia figures from the 2011 census.
I've used html titles for the tooltips.
The map renders fine in Chrome 27.0.1453.116, not at all in internet explorer 9.0.8112, haven't tried it in Firefox.
I'm not sure about the colour scheme, greyscale looks okay for the time being. Any suggestions and critique would be gratefully received.
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
Tuesday, 9 July 2013
Sunday, 12 May 2013
Skilmo - like FourSquare but for crafts and hobbies
Since last October I've been working on developing a crafts and skills website, and its quite presentable now. Its called SKILMO

Its like Foursquare or Indie Eyespy, but for crafts, skills and hobbies, so instead of getting points for checking off places you've been or people you've seen, you get point for learning to knit, or do origami, or playing guitar.
For me, the site has been a voyage of discovery in html, php, javascript and css, learning new tricks and figuring out how to do things. Adding more and more features as they become necessary.
But for you, the user, its just supposed to look nice and be easy to use. Feel free to have a click around
At weekends it has a lovely Morrison tartan background rendered in css, but during the week, it has a more sensible polka dot or checked pattern, except on Thurdays when its all floating flowers.
Signing up
Anyhoo, say you think yourself a crafty, arty kind of soul, then feel free to sign up. You'll need to click on the 'Register here' link on the home page, and it will take you to the great checklist of skills.
The list is a bit comprehensive and long so its got all the skills grouped into many categories. Graphic Arts for things like drawing, painting and printing; Textile Arts for knitting, crochet, cross-stitch and so forth; Photography for various genres, achievements and skills; Music for different musical instruments and performance related achievements.
You don't have to check off everything, you can add more strings to your bow later.
When you're content, click on one of the 'Calculate score' buttons. That will calculate how many points your skills are worth. The theory is that the more esoteric your skills are, the more points they're worth.
From the score page you'll be able to chose a username and password and sign up, so you can come back later and add more skills and crafts. You don't have to sign up, its not a biggie.
Members
Anyhoo, if you sign up with a username, you'll show up on the 'Members' page, and you'll have a profile page which lists all the skills you've checked off, and will let you upload jpeg images of the stuff you've done.
To check off more skills, like if you learn how to do double knitting, or manage to play a sold-out gig, or even figure out what chromolithography is, you can either go back to the checklist page, or you can go through the 'Categories' link to find the page for that specific skill, and then click on the 'I can do this skill' button.
There isn't much to stop you from just clicking on everything, and racking up all the points, except no one will believe you. You can prove you've done stuff, or just show off your first efforts at new crafts by uploading photos. At the moment the site only accepts jpegs and can only upload photos for skills that you've already checked off.
Photos
Once you've uploaded images, there's this awesome whole side of the website where you can browse all the photos that anyone's uploaded and upvote or downvote the best and worst.
For each picture, you can see the top five highest rated images for that skill and the top five highest rated images uploaded by that user.
So you'll be able to spend literally minutes browsing through literally dozens of photos of skills and crafts.
You might be inspired to try something new, or make something better.
These crafts and skills aren't difficult, anyone/everyone can do them.

Its like Foursquare or Indie Eyespy, but for crafts, skills and hobbies, so instead of getting points for checking off places you've been or people you've seen, you get point for learning to knit, or do origami, or playing guitar.
For me, the site has been a voyage of discovery in html, php, javascript and css, learning new tricks and figuring out how to do things. Adding more and more features as they become necessary.
But for you, the user, its just supposed to look nice and be easy to use. Feel free to have a click around
At weekends it has a lovely Morrison tartan background rendered in css, but during the week, it has a more sensible polka dot or checked pattern, except on Thurdays when its all floating flowers.
Signing up
Anyhoo, say you think yourself a crafty, arty kind of soul, then feel free to sign up. You'll need to click on the 'Register here' link on the home page, and it will take you to the great checklist of skills.
The list is a bit comprehensive and long so its got all the skills grouped into many categories. Graphic Arts for things like drawing, painting and printing; Textile Arts for knitting, crochet, cross-stitch and so forth; Photography for various genres, achievements and skills; Music for different musical instruments and performance related achievements.
You don't have to check off everything, you can add more strings to your bow later.
When you're content, click on one of the 'Calculate score' buttons. That will calculate how many points your skills are worth. The theory is that the more esoteric your skills are, the more points they're worth.
From the score page you'll be able to chose a username and password and sign up, so you can come back later and add more skills and crafts. You don't have to sign up, its not a biggie.
Members
Anyhoo, if you sign up with a username, you'll show up on the 'Members' page, and you'll have a profile page which lists all the skills you've checked off, and will let you upload jpeg images of the stuff you've done.
To check off more skills, like if you learn how to do double knitting, or manage to play a sold-out gig, or even figure out what chromolithography is, you can either go back to the checklist page, or you can go through the 'Categories' link to find the page for that specific skill, and then click on the 'I can do this skill' button.
There isn't much to stop you from just clicking on everything, and racking up all the points, except no one will believe you. You can prove you've done stuff, or just show off your first efforts at new crafts by uploading photos. At the moment the site only accepts jpegs and can only upload photos for skills that you've already checked off.
Photos
Once you've uploaded images, there's this awesome whole side of the website where you can browse all the photos that anyone's uploaded and upvote or downvote the best and worst.
For each picture, you can see the top five highest rated images for that skill and the top five highest rated images uploaded by that user.
So you'll be able to spend literally minutes browsing through literally dozens of photos of skills and crafts.
You might be inspired to try something new, or make something better.
These crafts and skills aren't difficult, anyone/everyone can do them.
And beyond
So I mostly created the site off my own back, with a bit of guidance on css from Robbie, without whom the site would still look like this.
There's still loads of functionality I ought to add, but really I could do with more people using the site and playing around with it, and finding bugs and problems, and little bits that could be better, easier, and more intuitive.
Wednesday, 17 October 2012
Further adventures in php and GeekSkills or whatever
Something unseen grabbed my throat and dragged me to google, my fingers danced over the keyboard and searched for php tutorials. Before me, on my screen, the aborted php script for my websitey idea appeared and my eyes were drawn to a typo.
I had spelt html wrong.
No sooner was it corrected, and ftp'ed across to chrisgilmour.co.uk, and it worked, a few lines of my database appeared in my browser, summoned from MySQL by my php script.
And so it began once more, resurrecting my ambitions and dreams of winning the internet with an arty, crafty, etsy, songkicky website.
I came up with a new name for it too, instead of GeekSkills. I needed something that wasn't in any dictionary, a new word that sounds a little like arts or crafts or skills. I came up with 'SKILMO', like more skills, but also like half hearing someone call my name.
Anyhoo, here are three pages I've crafted for the site:-
List of Skills - this is a list of all the skills on the database, there are hundreds of them
Skill information - this is the description and associated tags for one of the skills
Skills with a specific tag - This is a list of all the skills that have a specified tag
I want it all to work first, all the php, sql and MySQL stuff working together before I try to make it beautiful.
My next task is to make it so when you click on a Skill on the first page, it brings up the Skill information page for that skill.
And then some kind of form page where you click checkboxes for all the skills you have and crafts you can do, then it gives you an arbitary score and secretly saves your skillset.
I had spelt html wrong.
No sooner was it corrected, and ftp'ed across to chrisgilmour.co.uk, and it worked, a few lines of my database appeared in my browser, summoned from MySQL by my php script.
And so it began once more, resurrecting my ambitions and dreams of winning the internet with an arty, crafty, etsy, songkicky website.
I came up with a new name for it too, instead of GeekSkills. I needed something that wasn't in any dictionary, a new word that sounds a little like arts or crafts or skills. I came up with 'SKILMO', like more skills, but also like half hearing someone call my name.
Anyhoo, here are three pages I've crafted for the site:-
List of Skills - this is a list of all the skills on the database, there are hundreds of them
Skill information - this is the description and associated tags for one of the skills
Skills with a specific tag - This is a list of all the skills that have a specified tag
I want it all to work first, all the php, sql and MySQL stuff working together before I try to make it beautiful.
My next task is to make it so when you click on a Skill on the first page, it brings up the Skill information page for that skill.
And then some kind of form page where you click checkboxes for all the skills you have and crafts you can do, then it gives you an arbitary score and secretly saves your skillset.
Sunday, 5 June 2011
Dreams: On completing computer games
You know when you die and in some religions and belief systems, you're judged. Maybe at some pearly gates, some gent called Peter is deciding whether to let you in.
Yeah, sure, if you've done bad stuff like killing people, or pushing in front of queues, that really counts against you badly. But like if you've saved people's lives and always waited patiently in queues then that's a good thing, you get extra heaven bonus points or something. You probably broadly agree with that.
And book, reading books all the way through thats a positive, you get points for it, it broadens your mind, and enriches your life and the whole human race. So I reckon starting books and not finishing them, that's going to count against you right? Otherwise you could just go to a library and read the first page of loads of books, and rack up the points, so, you only get points if you finish a book.
Are we all agreed?
Good.
So now, computer games. I'm thinking to get a good gig in heaven with the maximum number of heaven points, the same logic applies and completing computer games is something I've got to do.
I'm comfortable with buying games and never playing them, heck I have plenty of Xbox 360 games, but no console to play them on.
But starting games and playing them a bit, and giving up, that's a big no no.
Its a matter of after-life and death, right?
Yeah, sure, if you've done bad stuff like killing people, or pushing in front of queues, that really counts against you badly. But like if you've saved people's lives and always waited patiently in queues then that's a good thing, you get extra heaven bonus points or something. You probably broadly agree with that.
And book, reading books all the way through thats a positive, you get points for it, it broadens your mind, and enriches your life and the whole human race. So I reckon starting books and not finishing them, that's going to count against you right? Otherwise you could just go to a library and read the first page of loads of books, and rack up the points, so, you only get points if you finish a book.
Are we all agreed?
Good.
So now, computer games. I'm thinking to get a good gig in heaven with the maximum number of heaven points, the same logic applies and completing computer games is something I've got to do.
I'm comfortable with buying games and never playing them, heck I have plenty of Xbox 360 games, but no console to play them on.
But starting games and playing them a bit, and giving up, that's a big no no.
Its a matter of after-life and death, right?
Tuesday, 10 May 2011
Dreams: Doom on the ZX Spectrum and Gameboy
I had a dream, well, not so much a dream, just this idea about computers and software and hardware, and how folk of my generation have seen home computer processing power improve and graphics improve, and maybe have a tiny inkling that back in the day, one guy in his bedroom could write the bestest computer game in the world, like Elite, but these days, it take a team of dozens of people.
Code used to be written really tightly to fit into a Vic 20's 20 kilobytes, or an Amstrad CPC's 64k or a Spectrum's 48K. Code had to be tight to fit, these days code sprawls and sprawls, and processing power always increases faster than the need to write tight code.
The limitations used to be things like how many colours you could have on screen at once, a pallet of 15 or 32 colours, resolutions less than 300 by 200. It seems so long ago. Now, the only colour limit it the human eye, and with screen resolutions, even the iPhone has the human eye resolution beaten. The limits for graphics are in terms of polygon count, 10,000 or 100,000 ain't much of a difference.
Anyhoo, what I'm imagining is if somehow could could get twenty-first century games on old 8-bit machines, with the graphical limitations inherent to them.
Doom.
I remember when I first saw Doom, the graphics blew my mind, on my dad's 486 DX2 PC. But compared to state of the art games graphics now, it was a bit pants.
What I wonder is, What would Doom look like on 8-bit machines?
Well, on the ZX Spectrum, 15 colours in two colour 8x8 blocks for a screen resolution of 256x192, it would look like this:-
And on the Nintendo Gameboy, four shades of green/gray at 160x144, it would look like this:-
I reckon the Game Boy version would be bestest.
It would be neat if I could be bothered to do some kind of gif animation of the action, but that's a little too much hassle. For the ZX Spectrum screen shot I used a utility called zxspectrumizer, from this chap and for the Gameboy screenshot I just used good old Photoshop.
UPDATE
Looks like some Hungarian mob put together an Spectrum version after all
Its a bit crap
This version of Wolfenstein 3D looks a bit better
Code used to be written really tightly to fit into a Vic 20's 20 kilobytes, or an Amstrad CPC's 64k or a Spectrum's 48K. Code had to be tight to fit, these days code sprawls and sprawls, and processing power always increases faster than the need to write tight code.
The limitations used to be things like how many colours you could have on screen at once, a pallet of 15 or 32 colours, resolutions less than 300 by 200. It seems so long ago. Now, the only colour limit it the human eye, and with screen resolutions, even the iPhone has the human eye resolution beaten. The limits for graphics are in terms of polygon count, 10,000 or 100,000 ain't much of a difference.
Anyhoo, what I'm imagining is if somehow could could get twenty-first century games on old 8-bit machines, with the graphical limitations inherent to them.
Doom.
I remember when I first saw Doom, the graphics blew my mind, on my dad's 486 DX2 PC. But compared to state of the art games graphics now, it was a bit pants.

Well, on the ZX Spectrum, 15 colours in two colour 8x8 blocks for a screen resolution of 256x192, it would look like this:-


It would be neat if I could be bothered to do some kind of gif animation of the action, but that's a little too much hassle. For the ZX Spectrum screen shot I used a utility called zxspectrumizer, from this chap and for the Gameboy screenshot I just used good old Photoshop.
UPDATE
Looks like some Hungarian mob put together an Spectrum version after all
Its a bit crap
This version of Wolfenstein 3D looks a bit better
Sunday, 8 May 2011
Programming: Java text board game
Gor, it must be getting on for a year, since I uploaded that game what I wrote in Perl to SourceForge, you can download it from here if you're into that sort of thing. Its a bit like the programs I used to type in from Amstrad Action or Amstrad Computer User.
Anyhoo, I've now ported it across in Java, and tidied it up a bit, making the code a bit more concise. Its taken me a while because I didn't actually know how to program in Java, luckily I managed to borrow this book from my girlfriend's sister.

Its all right, not too confusing, I'm not even halfway though but I've got enough of it in me to port perl to java.
The basic premise of the game is kind of like checkers, apart from you add one new piece to the board every turn and the stacks explode. Actually, its only like checkers in that its played on a 8x8 board and you can stack pieces, other than that, its like in games like Doom or Halo where you can blow up oil drums and they set of nearby oil drums in a chain reaction.

It must have been back in 1993 when a friend showed me a version of the game on his Acorn Archimedes, and then a few months later I was going through all my old ACU magazines typing in all listings and ended up with the same game. I hadn't see it since so I figured I could create my own version on modern computers.
For a player versus player game, it game works like this basically

The main difference I found between perl and Java was that in the latter you have to is statically typed whilst the former is dynamically typed. I think that means you have to define what sort of data all the variables are, whether they're integers or strings and so on. Also, with things like arrays you have to state how long they are before you use them, rather than just adding stuff into an array whenever you want. And lastly getting user input from the keyboard is a little bit more different in java than in perl. It took me about a week to figure it out.
Anyhoo, once I'd nailed all that it was easy. The gameboard is a great three dimensional integer array, 10x10, but it ignores the border squares and uses one layer for each player. You play a turn, it checks whether there's any 'explosions', explodes them and then checks again until its exhausted its explosives, then the next player takes a turn. This repeats until one player or the another has been annihilated or someone quits.
Then for playing against the computer it does the same thing but substitutes in a routine for chosing where to play. It builds itself a little list of what grid squares do the most damage, which are most aggressive, or which are safest, and then randomly selects the most appropriate.
Games take around twenty minutes to play, or maybe 200 turns. I've managed to win in 140 turns, which I guess is the closest thing to a high-score at this stage.
If you want to play, or just peer at my well leet coding, you can download the source code from this page.
ChainOfWar is the java version
plainofwec is the perl version
You'll need to compile the code to get it to work. If you don't know what that means, then you ought to have a long hard think about what you want to get out of life. Do you want to be a creator or a consumer? Do you personally want to leave the world a better place than how you found it. Do you want to grow as a person, or just wallow until dementia hits.
Anyhoo, I have a plan. Whilst this it just a command-line/text based version of the game, I'm going to use java's gridbag class to do a windows version that ought to be a bit more fun to play, then I'd going to do some kind of web applet version so you can play it online. Then, I know, crazy, I reckon its just the same learning curve to do an android and iPhone version that I can sell and become one of these millionaires.
Its all right, not too confusing, I'm not even halfway though but I've got enough of it in me to port perl to java.
The basic premise of the game is kind of like checkers, apart from you add one new piece to the board every turn and the stacks explode. Actually, its only like checkers in that its played on a 8x8 board and you can stack pieces, other than that, its like in games like Doom or Halo where you can blow up oil drums and they set of nearby oil drums in a chain reaction.
It must have been back in 1993 when a friend showed me a version of the game on his Acorn Archimedes, and then a few months later I was going through all my old ACU magazines typing in all listings and ended up with the same game. I hadn't see it since so I figured I could create my own version on modern computers.
For a player versus player game, it game works like this basically
The main difference I found between perl and Java was that in the latter you have to is statically typed whilst the former is dynamically typed. I think that means you have to define what sort of data all the variables are, whether they're integers or strings and so on. Also, with things like arrays you have to state how long they are before you use them, rather than just adding stuff into an array whenever you want. And lastly getting user input from the keyboard is a little bit more different in java than in perl. It took me about a week to figure it out.
Anyhoo, once I'd nailed all that it was easy. The gameboard is a great three dimensional integer array, 10x10, but it ignores the border squares and uses one layer for each player. You play a turn, it checks whether there's any 'explosions', explodes them and then checks again until its exhausted its explosives, then the next player takes a turn. This repeats until one player or the another has been annihilated or someone quits.
Then for playing against the computer it does the same thing but substitutes in a routine for chosing where to play. It builds itself a little list of what grid squares do the most damage, which are most aggressive, or which are safest, and then randomly selects the most appropriate.
Games take around twenty minutes to play, or maybe 200 turns. I've managed to win in 140 turns, which I guess is the closest thing to a high-score at this stage.
If you want to play, or just peer at my well leet coding, you can download the source code from this page.
ChainOfWar is the java version
plainofwec is the perl version
You'll need to compile the code to get it to work. If you don't know what that means, then you ought to have a long hard think about what you want to get out of life. Do you want to be a creator or a consumer? Do you personally want to leave the world a better place than how you found it. Do you want to grow as a person, or just wallow until dementia hits.
Anyhoo, I have a plan. Whilst this it just a command-line/text based version of the game, I'm going to use java's gridbag class to do a windows version that ought to be a bit more fun to play, then I'd going to do some kind of web applet version so you can play it online. Then, I know, crazy, I reckon its just the same learning curve to do an android and iPhone version that I can sell and become one of these millionaires.
Saturday, 26 June 2010
The Plain of Wec

So, the other week I wrote me a game in perl. Its a thrilling board-based turn-based strategy game where you must defeat a super-intelligent AI player. You enter co-ordinates to build up things that explode and by building up loads of things you can set up devastating chain reactions.
You can download it from SourceForge here.
As its in perl you might have to install some kind of software to run it on your computer, my operating system is Ubuntu and it comes with perl preinstalled, but on Windows computers try Strawberry perl.
I find the game fiendishly addictive, and I'm forever coming up with new strategies to defeat my computer foe, and then tweaks to the computer's AI to make it even harder.
My record is defeating the computer in 119 turns.
Can you beat that?
Saturday, 19 June 2010
Hating Ruby on Rails so much
I have nailed Python, and hammered perl, I am the coding ninja!. Its taken me about a fortnight from getting the O'Reilly book to churning out addictive turn-based strategy games and personal finance suites in perl.
I ordered Ruby on Rails for Dummies, and waited patiently. Fate smiled on me and allowed me to have plenty of free time to get my teeth into it and so this morning I set forth on what I hoped would be an exciting new adventure in programming.
No such sodding luck.
Fucking hell, Barry Burd, author of Ruby on Rails for Dummies is a cunt.
I have spent all day wading through the first few chapters installing and trying to install all the various packages and tools and vaguely related stuff to get Ruby on Rails working and its pissing me off so much I might have to rip my wee netbook in half, chuck it in the garden, go to my storage locker get a pick axe, return to my garden and annihilate my netbook.
These are the 'tarded things I have to install
Fourteen hours I've been at it. Fourteen hours with just a brief break for Doctor Who.
Every sodding page of the damned book refers me to 'the book's website' which just so happens to be the author's personal website, which looks like it hasn't been updated since '92.
Look, I know that Ruby is a dynamically typed interpreted reflective object-orientated language, but its a cunt to install.
With perl, I was churning out the first beta release of my accounting software by now, and had finally figured out how I could have written a spider to rip the entire Bowlie archive.
But with Ruby on the shit-eating Rails, I am shouting at the screen and hacking at the damned book with a kitchen knife.
You hear me For Dummies publisher John Wiley & Sons, that's it, you've lost yourself a customer, never again am I going to buy any of your books again, its O'Reilly for me from now on!

No such sodding luck.
Fucking hell, Barry Burd, author of Ruby on Rails for Dummies is a cunt.
I have spent all day wading through the first few chapters installing and trying to install all the various packages and tools and vaguely related stuff to get Ruby on Rails working and its pissing me off so much I might have to rip my wee netbook in half, chuck it in the garden, go to my storage locker get a pick axe, return to my garden and annihilate my netbook.
These are the 'tarded things I have to install
- Ruby
- Rails
- Java
- RadRails
- Aptana Studio
- Git
- Curl
- Bash
- RubyGem
- MySfuckingQL
- MySQL cunting cock nipples Administrator
Fourteen hours I've been at it. Fourteen hours with just a brief break for Doctor Who.
Every sodding page of the damned book refers me to 'the book's website' which just so happens to be the author's personal website, which looks like it hasn't been updated since '92.
Look, I know that Ruby is a dynamically typed interpreted reflective object-orientated language, but its a cunt to install.
With perl, I was churning out the first beta release of my accounting software by now, and had finally figured out how I could have written a spider to rip the entire Bowlie archive.
But with Ruby on the shit-eating Rails, I am shouting at the screen and hacking at the damned book with a kitchen knife.
You hear me For Dummies publisher John Wiley & Sons, that's it, you've lost yourself a customer, never again am I going to buy any of your books again, its O'Reilly for me from now on!
Saturday, 22 May 2010
Python text document stats script
Desperately I spend the last three weeks refreshing my knowledge of Python, the easy peasy scripting language I'd once used in my youth to test CD players and hi-fi RS232 commands. I re-acquired Dive Into Python and Python For Dummies and ploughed through.
Sadly I didn't get the job I was learning it for, but instead refired my enthusiasm for learning programming languages. So, I've acquired Learning Perl and when that is done I'll be trying my hand at Ruby, just like the cool kids use.
I wrote me a wee program in Python that analyzes the text file of my 2001 novel Shag Times and comes up with various statistics for it.
I plan to re-write the same program in Perl as soon as I've finished reading Learning Perl, and then write the same program again in Ruby if that's even possible.
Can someone recommend me a good book for learning to program in Ruby?
Sadly I didn't get the job I was learning it for, but instead refired my enthusiasm for learning programming languages. So, I've acquired Learning Perl and when that is done I'll be trying my hand at Ruby, just like the cool kids use.
I wrote me a wee program in Python that analyzes the text file of my 2001 novel Shag Times and comes up with various statistics for it.
I plan to re-write the same program in Perl as soon as I've finished reading Learning Perl, and then write the same program again in Ruby if that's even possible.
### Program to do the following
### * open shagtimes.txt
### * provide a word count
### * count unique words
### * provide top ten most popular words
### * provide all single occurance words
### * calculate average word length
### * find longest word
import textwrap
# Opening Shag Times and processing it a bit
book = open('shagtimes.txt')
book = book.read()
book = book.lower()
### Code to remove punctuation
stuff_to_replace_with_space = (".", ",", "?", "/", "=", "-", ";", ":")
stuff_to_remove = ("\'", "(", ")", "\"")
for item in stuff_to_replace_with_space:
book = book.replace(item, " ")
for item in stuff_to_remove:
book = book.replace(item, "")
print "======================================="
# Doing the word count
book = book.split()
wordcount = len(book)
print "The document contains %i words in total" % wordcount
print "======================================="
# Doing the unique count
uniques = []
for item in book:
if item not in uniques:
uniques.append(item)
uniquecount = len(uniques)
print "The document contains %i unique words" % uniquecount
print "======================================="
uniques.sort()
# Finding top ten popular words
print "The top ten most used words:-"
occurancelist = []
for item in uniques:
occurances = book.count(item)
occurancelist.append((occurances, item))
occurancelist.sort()
occurancelist.reverse()
for item in occurancelist[:10]:
print item
print "======================================="
# Finding single use words
print "Words that were used only once:-"
singleuse = []
singleusecount = 0
for item in occurancelist:
c, w = item
if c == 1:
singleuse.append(w)
singleusecount+=1
singles = ""
while singleuse:
for item in singleuse:
singles = singles + (singleuse.pop()) + ", "
singles = textwrap.wrap(singles, width=70)
for i in singles:
print i
print "======================================="
print "A total of %i words were used only once" % singleusecount
print "======================================="
# Finding average word length
chartotal = 0.000
for item in book:
chartotal = chartotal + len(item)
avechar = chartotal/wordcount
print "The average word length was %.3f letters long" % avechar
print "======================================="
# Finding longest word
longlength = 0
for item in uniques:
if len(item) > longlength:
longlength = len(item)
print "The longest word was %i letters long" % longlength
print "These words were that long:-"
for item in uniques:
if len(item) == longlength:
print item
print "======================================="
Can someone recommend me a good book for learning to program in Ruby?
Subscribe to:
Posts (Atom)