Saturday 28 February 2009

Project Euler, Problems 34 and 39

Two more problems solved!

Problem 34
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits.

This was pretty straightforward. When we consider that 9! = 362880 we only have to do a few sums to get an upper bound on the numbers that we must consider. Then it is a simple case of putting together a loop which gets the digits of a number, sums the factorials of the digits and compares it with the number. There is a similar problem which I hope to have coded a routine for by the end of the weekend involving fifth powers of digits.

Problem 39
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120 - {20,48,52}, {24,45,51}, {30,40,50}. For which value of p ≤ 1000, is the number of solutions maximised?

I solved a similar problem to this a few days ago; this was a bigger problem because of searching through a large set of perimeters. However, with a bit more maths it wasn't difficult to get conditions to impose and then search through - for example, we can deduce with only a little work that p/3 < c < p/2 and that p must be a divisor of 2ab. The program took no time at all to find the p which had the most solutions (incidentally, the perimeter value found had 8 solutions!).

So that leaves... Four problems to solve? Really? Am I actually that close to finishing another one of my 101 things?!

Friday 27 February 2009

The Man Who Smiled

I really like Henning Mankell's Kurt Wallander mysteries. My friend Dave got me into reading them a few years ago when I first started getting interested in reading crime stories and noir, and The Man Who Smiled is the third Wallander novel I've read. I think that the brilliant thing about reading these stories is the setting and the atmosphere that Mankell creates. The crimes are well thought out, as is the description of the way that Wallander and the team in Ystad eventually solve them. The main draw for me is the way that you feel like you are there with him as he follows the clues and makes the deductions that lead him to the answer.

When he is on the job, Kurt Wallander eats poorly, sleeps little and gradually becomes more and more dishevelled. His personal life is an endless series of thoughts to call his family - which he invariably puts of to later - and reflections on why he became a police officer (he can't remember any more). In The Man Who Smiled, he begins his journey even more lost than usual. Wallander has taken a leave of absence that has lasted over a year, ever since he had to take a man's life in self-defence. On the day that he is to officially resign he discovers that a friend of his has been murdered, and in an instant he decides to return to work, and so the cycle begins again for him.

The Man Who Smiled is a good mystery story, although perhaps not the best place to start for people who've not read any of the other Wallander novels. You should definitely try One Step Behind if you get the chance, which is a fantastic mystery story, again permeated by the brilliant atmosphere that Mankell expertly builds up.

Thursday 26 February 2009

Project Euler, Problems 9 and 28

I was just thinking the other day that I hadn't done any Project Euler problems in a while, and having a look down the list of problems a few jumped out at me as "do-able". Both of these required very little computing - in fact I did the second mentioned here with just a calculator once I had done some thinking.

(as a side note, I've also been working on thing number 62, to find the number of stacked 4-tangles; I've proved a few things which my previous assumptions had relied on, made it more concrete, and am at the point where I need to use a Maple program in order to find things and split things up. Not quite there in my C++ knowledge in order to be able to do that!)

Problem 9
Find the only Pythagorean triplet {a,b,c} such that a + b + c = 1000.

From this we can take a few bits of information:

  • a^2 + b^2 = c^2
  • a + b + c = 1000
  • a < b < c and a, b, c are all positive integers
By manipulating the two first lines there, we can arrive at the expression
  • ab = 1000(500 - c)
This is a good line to get to! It tells us that c is less than 500 and that the product of a and b is divisible by 1000. Also, as a < b < c < 500 we can deduce that 334 < c < 500. These conditions, combined with the main Pythagorean triple condition, are enough to impose a range of conditions for a simple search in C++, in order that we arrive at the answer.

Problem 28
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: (looks better on Project Euler site, here)

21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13

It can be verified that the sum of both diagonals is 101. What is the sum of both diagonals in a 1001 by 1001 spiral formed in the same way?

I didn't need C++ to solve this. I extended the spiral out to 7 by 7, so I could get a better feel for the numbers in the diagonals. I split them up, and obtained (in the end) three sequences of numbers. From these I arrived at three quadratic relations that you could get the three sequences from, and then by summing the series I got the answer. Simple really - big numbers though!

This takes my total to 19 now, six more to go. I have a list of a few that I might try next. I was originally aiming to get my 25 done by the end of February. I'm now aiming for the end of March, and also hoping to get thing 62 done by then as well (or at least, to have the answer and be writing it out from all of my rough notes).

Tuesday 24 February 2009

The Shack

A few weeks ago my mum said, "I've got a novel for you to read; it's called The Shack and... Well, I'm not really enjoying it, but I want someone else to read it so I know I'm not crazy for not liking it."

"What's it about?" I asked.

"It's about this man, and his young daughter is killed by a serial killer, and then a few years later he gets a note from God saying that he has to come to the shack where his daughter was killed - "

"O-kaaay..."

"- yeah, and then, when he's there, he meets God. And God is three people: an old black woman, a thirty-something Middle-Eastern man and a young Asian woman."

"Shall I just read it?"

"Maybe you'll like it more than I did," she said, "I skipped the last quarter to go straight to the end..."

So, once I had finished a stack of library books I borrowed it and started reading. The basic outline is exactly as my mum described it, and one would think that that opened up a lot of possibilities for an interesting story. Instead...

I'm going to be as concise as possible about the experience; from the front and back cover heaping praise on it, and the two pages of people giving quotes inside it - and in some ways throughout the story - it smacks of being a book that is going to desperate lengths to get itself noticed. At points it does this to the distraction of the story itself. There's a covering story, that the person who has written it is a friend of the person who all this happened to; this device bookends the story. The (fictional) writer has done a disservice to his friend; the narrator often refers to the protagonist's grief as The Great Sadness - italicised every time and always with capitals - and as strange as it seems at those (frequent) points it becomes absolutely ridiculous when the protagonist refers to his grief as The Great Sadness when talking to others...

My mum says that she hated the book; I don't know if I would go that far. I couldn't recommend it to anyone, I really couldn't. Some elements of the story challenged my own personal faith, but not in a positive way - in some ways it made me think, "Am I foolish for having religious faith?" One of the themes that runs through the story is that humans by and large don't really understand that faith (the Christian faith) is not about rules and religions, but about relationships. But then, why should we believe the message of the author? What does he offer apart from an argument that "other people get it wrong"?

Fundamentally, I didn't enjoy reading the book. The pacing is weird, the writing is quite strange at times and to my ear the dialogue rarely rang true, as if it had been written for two people sat on a chat show couch having a staged conversation. The denouement was the final straw, offering with one hand proof that the man had experienced everything that he said he did up at the shack and then taking away with the other what little internal logic the story had by summing up the consequences of this in a few lines.

As I said, the covers carry many endorsements and facts about sales - New York Times #1, a million copies sold - and the inside back cover asks people to blog about the book once they've read it, get the word out, etc. Well, here's my review: "Don't read The Shack. It's a frustrating, poorly written thesis on faith dressed up as an Oprah/Richard & Judy novel of the week."

Vegetarian Month I Update 3

Only a few days left to go; I'm not going to rush back into eating meat with a big steak on Sunday - I'll probably have a piece of fish or something - but I am looking forward to eating meat and fish again. I didn't do this out of any big moral imperative, but rather to try and eat differently, possibly more healthily; this has also meant that I have cooked a lot more over the last month, and while my family might claim that I have been quite limited in the range of foods that I have eaten, at the same time I feel quite good for having tried a range of recipes with them. Things definitely got better for me when I started to follow recipes as well, rather than just make them up as I went along (as I have noted previously).

I'll take next February as one of my two remaining vegetarian months I think, and try to have this April as my other one. Somewhere amongst all this I'll do my thirty days of five-a-day as well - probably; at the moment I'm looking into the whole five-a-day thing due to something a friend told me about the health benefits of following that being a myth (not that I want to excuse myself from eating five-a-day, but if there is no benefit I would rather add something else to the list).

Saturday 21 February 2009

Scott Pilgrim's Precious Little Life

I've been meaning to read Scott Pilgrim for a very long time; recently, I don't know why, that feeling has been building up in me, a desire to find out what it's all about. I had an idea of the basic story - that a guy has to face the seven evil ex-boyfriends of the girl of his dreams - but had no idea of the specifics of it. I'm not sure I have ever read anything else by the creator of the series Bryan Lee O'Malley, but whenever I have come across a Scott Pilgrim illustration I have smiled at how cool it looks.

(I have seen various things recently about volume five being released, and had heard that Edgar Wright and Michael Cera were in the process of making a film based on the first few volumes; maybe that's why it has been sticking in my mind so much)

I've been economising recently, cutting down on what I do and where I go (credit crunch plus slow work period as a freelancer over the last few months) but last Thursday when I was in my local comic shop (Worlds Apart, near Lime Street Station in Liverpool) my regular order came to less than a fiver. A slow week for comics. And I thought, "Hmmm, maybe, maybe now is the time to see what Scott Pilgrim is like...?" I had a look around and finally (after asking) found volume one (it had been placed with manga due to the style of the artwork).

Normally, when I go to the comic shop I go immediately to the train station after that and get the train home, maybe read a few comics on the way, and read the rest after dinner. On Thursday I was going to meet my writing group, and then we went on for dinner. I read the two comics I had bought, and thought, "I'll read the first chapter of Scott Pilgrim before bed." (it is a graphic novel, broken down into chapters inside)

Well.

I couldn't put it down. The combination of artwork, story, technique, romance, humour - if I hadn't been lying back in bed, it would have floored me. This first volume was released back in 2004, so I'm playing catch up on the cool curve I guess; I had no idea just how absolutely brilliant it was. I like all kinds of comics and graphic novels, but apart from some of the webcomics I read I very rarely go for series that have a humourous focus. To say too much about where Scott Pilgrim gets its laughs from would spoil the surprise - the final twenty pages or so had me alternating between laughing out loud and literally gasping with delight. The dialogue, the story, the artwork - it combines to make a perfect entertainment.

I've looked over the last five paragraphs and realised that really this is a terrible review: aside from the one line synopsis, which is based on what I thought I knew about Scott Pilgrim before I read it, I have told you nothing about what happens or anything really. All I have done is gush about how I came to read it and how fantastic it is. Oh well.

(by the way, if anyone reading this has ever read Scott McCloud's Understanding Comics, it struck me that Bryan Lee O'Malley understands comics - the various things that he uses in it that McCloud talks about in the book just jumped out at me, and not in a distracting, obvious way, just the way that he framed things, used motion lines, drew characters and everything...)

I'm economising, but I am going to put pennies and pounds to one side over the coming weeks and months so that I can get the other four volumes that are currently available. Scott Pilgrim's Precious Little Life is a fantastic slice of pure joy, a wonderful piece of sequential art and a bloody good story.

Recent Books

Saturn's Children by Charles Stross
I've read a few novels by Charles Stross since I've started 101/1001, and while I'm not always blown away in the same way I am when I read something by, say, Peter F. Hamilton, I am always left entertained having read something of Stross's. Saturn's Children is a good mystery story, and has as its backdrop the society of robots living in the solar system after humans have become extinct.

The central mystery itself seemed to unravel in a fairly obvious way as time went on (so, for example, you know who the mysterious aristocrat really is long before you have her identity confirmed) but the background is so well thought out and put together that you just find yourself carried along for the ride. The central character being an obsolete sexbot makes for an interesting perspective, as do the observations about how ridiculous the robots' creators were (a human's frailties compared to a robot's resources).

So far, I'd recommend everything I've read by Charles Stross, and Saturn's Children is no exception; he has an amazing imagination and head for all of the little details that go into making something that feels like a real world. If you're new to Stross though, I'd start with The Atrocity Archives or Halting State, I think they're better stories.

The Hound of the Baskervilles by Arthur Conan Doyle
It should be obvious by now to any regular reader of this blog (all three of you) that I am a sucker for a good mystery story. I read A Study In Scarlet years and years ago, but have never read The Hound of the Baskervilles until now (although I was aware of the mystery and what the solution to the mystery was).

Sherlock Holmes is a brilliant creation; far better writers than myself have described how fantastic he and Doctor Watson are. Doyle really makes them jump out of the page at you as fully three-dimensional characters. The fantastical leap in the story is not connected with the ghastly hound of the title; as with every Holmes story the fantastic thing is Holmes himself, and the speed of the deductions that he makes, the evidence that he bases them on. While he is always right, and the explanation matches up, it makes for an excellent read on the strength of Doyle's creations and the mysteries that he conjures up. You suspend disbelief that a man could be that intelligent and go along with it because Holmes is such a fascinating man.

The 100 Classic Novels app I have for my DS has some Holmes stories, I'll have to give those a look some time soon.

Monday 16 February 2009

Flash Fiction: On Charles Bridge

On Charles Bridge
Nathan Ryder

To Sophie Barnes' blue-grey eyes there was no more beautiful sight in the world than the view from Charles Bridge. She had visited Prague several times, both on business for Grover & Macmillan and on holiday; normally she would have to contend with several thousand other people streaming across the bridge, but it was dawn, and she was able to appreciate the beauty of the city by herself.
She pulled the coat tightly around her, warding against the chill in the wind that was tugging slightly on her pale blonde hair. Sophie tucked a stray strand away behind her ear, and checked her watch. Sunrise was in ten minutes, and already she could see the pale light creeping up from further down the river. Her flight was in two hours, but it was only a short taxi ride to collect her bags from the hotel and then on to Prague-Ruzyne International Airport. She had time, and she let her eyes gaze towards the coming sun, drinking in the colours as they started to spread.
“Hello Sophie.”
Angelo Mori's accent always surprised her; there was a slight trace of his childhood in Pisa, but this was more firmly dominated by the New England business colleges that he had attended on his way to becoming one of the biggest property developers on the East Coast.
Sophie knew every inch of him, and yet still her eyes lingered as she looked at him now, tracing every detail of his expensive coat up to his perfectly chiselled face. Once, she had fallen in love with his eyes, pools of calm that radiated warmth to the rest of his face. He had let his raven black hair grow slightly longer since she had last seen him, and there was a slight greying at his temples that hadn't been there before. She felt that old attraction surfacing again, and with it a shiver as she realised how shallow the grave of that buried feeling had been.
“Well, aren't you going to say anything?”
It was only when he spoke again that she realised that she had just been staring at him and she had no idea how long they had both stood there. Sophie struggled to keep her voice under control, as a wave of emotions passed through her: sudden delight at seeing Angelo again, surprise at how quickly she found herself falling in to those brown eyes and shock as the memory of how they had parted that last time swept back in to her mind, becoming as clear as the breaking dawn.
Finally, she spoke.
“What... What are you doing here Angelo?”
She immediately felt foolish for asking, but if any trace of it crossed her face Angelo showed no sign of having seen it.
“Sophie,” he said, stepping towards her, smiling the same tender smile that he had shown her on their first date three years earlier, “Sophie, is it not obvious? I am here for you.”
He stopped two feet from her, and she continued to just look at him, unable to find words after what she had said the last time she had seen him.
“Do you have nothing else to say?” he asked after a moment.
Sophie felt her heart racing, and she tried to get a hold of herself as she asked, “How did you find me?”
“Carter told me you were here,” he replied, smiling lightly, and Sophie swore mentally at Carter Macmillan, for revealing the information. He might be her godfather, he might be her boss, but for the longest time he had been the most insufferable wannabe Cupid when it came to her relationships.
“Don't be angry with him, Sophie, he only wants the best for you – as I do. I should have known where you would be when I heard you had taken a short leave of absence,” Angelo continued, stepping closer and raising a hand to touch her arm, “You always said that Prague was your favourite city in the whole world.”
“And I suppose you just flew here in your private jet when you found out where I was?” she said, feeling a small flush of anger hit her cheeks.
Angelo did not respond to her tone of voice, saying simply, “I had to Sophie. Had you been in London at work I would have gone there; had you been on business in Melbourne I would have followed. I had to see you, I had to tell you - ”
“Tell me what?” she asked, her heart fluttering wildly. All of the control that she had had just moments earlier had evaporated, and she felt her heart and her head struggling for ownership of her body.
“Sophie, you must know. I could not say those words before. I am so sorry... I was a fool; we had both been hurt, but I failed to see – no, I failed you. I should have been a greater man than I was for you. I think... I think I can be that man now. If you will let me.”
“Angelo,” she said, after a moment's pause, shaking his hand from her arm, “Angelo, I can't... I can't - ”
“Yes, yes you can Sophie!” he said, taking hold of her with both hands and drawing her close to him, his accent breaking down as he became more animated. “Us together... It is what we have both been looking for all of our lives! You know it, I know you do. I let my past get in the way, and you let yours trap you, unable to feel that which you know you want to feel, that you long to feel.”
“Please, let me go - ”
“Sophie, I lo-”
“No Angelo!” she sobbed, “Don't! Don't say it!”
“Sophie,” he said, composing himself and fixing her with his large brown eyes, “Sophie, I love you.”
Her head was awash with thoughts as he continued, “I know you love me Sophie, I know you don't think that you deserve happiness – but you do! You're beautiful, and you're brilliant and you could be happy if you would just let yourself!”
She struggled for a second to escape his hold, but then he pulled her closer and kissed her. Her lips responded to his kiss, gentle at first, and then stronger. Her hands snaked around his muscular body and embraced this wild, passionate man who she has loved since the moment she first saw him.
A few minutes later they stand there holding each other. Sophie felt more secure than she had felt in her whole life, her head resting on the chest of the man she loved, together as the sun's first rays hit Charles Bridge.

*
Creative Commons License
This short story is released under a Creative Commons Attribution-Noncommercial-No Derivative Works License. Feel free to repost and share it with others, so long as you credit me (Nathan Ryder, 2009) as the original author and link back to this page. It would also be nice if you dropped me a comment!

Vegetarian Month I Update 2

So. I found it increasingly difficult to stick to five-a-day (which I know, I know, I shouldn't really, given that I am not eating meat this month) but have found it easier this last week eating as a vegetarian. This is primarily because I started looking for and following recipes, rather than just saying, "Hmm, a big flat mushroom baked in the oven with some red onion? Yeah, that's kind of like a burger!" when clearly, clearly, it is not.

Have made soup twice this last week, relatively low in calories and very satisfying, and have also tried a few veggie delights such as nut roasts and meat free burgers - the latter taste nothing like meat, but oddly have a satisfying burger-ness to them. I'm still not convinced that I would ever want to be vegetarian long term, but it's not bad.

And the good news is that between the 2nd of February and the 14th I lose four pounds! If I can keep that sort of weight loss up over the next two weeks I would be very happy indeed. Hoping to carry over good cooking habits (I would have never thought to make soup from scratch before) into the next few months, combined with more walking and exercise, to try and shift a stone before I go to the USA in the summer. Perhaps April will be my second veggie month.

So. I'm quite happy. Onwards and upwards.

Monday 9 February 2009

Vegetarian Month I Update

So I have totally failed at getting my five-a-day consistently, due to a couple of days where I just didn't feel much like eating, but I am still on track with my primary goal of eating vegetarian for February. Have been cooking a lot more in the last week, but due to my own stupidity have not made many things which I would honestly like to eat again.

Until today, when I decided to make soup. I looked in the recipe book which my friend had got me for Christmas, and saw two recipes which seemed attractive, one for leek and potato soup and one for a creamy spinach soup. However, I didn't have any leeks for the one, and I had no cream or lima beans for the other. So I decided to try and make a half portion of a fusion of the two, substituting some red and baby white onions for the leeks and adding the spinach.

And you know, it turned out alright. Sure, the soup is a disturbing grey/green colour, but it is tasty. My only complaint with myself is that I didn't trust myself to make something nice, and so in making a half recipe I ended up with only two servings. That's OK though, next time I'll make a larger recipe, enough for half a week at least.

The recipe from the last week which I definitely won't be trying was for a lunch that I made last Thursday. My sister put it best when she said (through tears of laughter), "At one point did you think, 'giant flat mushrooms stuffed with red onion and baked in the oven, served like burgers on batches - that'll be lovely'???"

As my family have pointed out, the key to all of this is preparation, thinking ahead to what I'm going to have (since a. I'm cooking all of my own meals - good practice for living alone - and b. I'm limited by what I eat - not that I am very fussy - and what is available). Tomorrow or Wednesday afternoon I'm going to make a pan of some tomato-y, Quorn mince-y, bean-y chilli that'll last for a couple of days, and for which I can just cook some carbs each day to go with it.

And next week will be soups galore I think (especially since I have three separate appointments at the dentist for fillings, for some reason the three teeth couldn't be done together or even combine a few of them).

I am missing meat and fish a bit, but have had no real temptation to break the "diet". All in all, going well!

The Chronicles of Narnia

I've spent the last nine or ten days re-reading the seven Narnia books by C. S. Lewis. I last read them when I was much younger; I really can't remember how long it must be. The more I think about it, the more I am convinced that it must be over ten years. I had only a few vague ideas about the plots of them - apart from "The Magician's Nephew" and "The Lion, The Witch and The Wardrobe", both of which were quite clear in my mind - although I could still recall the names of most of the principal characters.

I was quite surprised, in re-reading them, just how well the books hold up. I feel as if there has been a bit of a backlash against C. S. Lewis in recent years, and that there is an idea he just wrote seven religious instruction pamphlets disguised as children's literature. While it's certainly true that there is a lot of Christian symbolism throughout the novels, I never felt that it was there at the expense of the stories.

"The Voyage of the Dawn Treader" was my favourite having re-read the novels, and that said I am nervous about the proposed film. In some ways it is quite an episodic story, as the protagonists sail from one place to another searching for the seven friends of King Caspian's father, but all of these incidents are vital to the story; will the film be able to keep them all? At the same time it has no episode which can really be built up to a large battle, and set piece battles were big parts of the previous two Narnia films.

No matter your age, if you haven't read the Narnia books before you should give them a go; if you have read them before then I'd suggest you make time for them again, on the whole they make for a really interesting and engaging fantasy sequence - certainly the most spiritual I've read, and that in itself was very refreshing.

Saturday 7 February 2009

Two Sentence Story

It's not one of my 101 things, but I have submitted a Two Sentence Story to TwoSentenceStories.com!!! I would be very grateful if all five of my readers went and read it, and if you like it please give me a good vote!

The story is called "Timing" (with big thank yous to Sarah for the suggestion!) and you can vote for it by clicking here.

Thank you!

Wednesday 4 February 2009

Road Trip Update!

This is just a bit of a shout-out really asking for advice from US readers or readers with a greater knowledge of the USA than me and my friend David.

As I said a few weeks ago, we booked our flights for our road trip; we're now looking to book hotels for the beginning, middle and end of our trip, i.e., in New York, Las Vegas and San Francisco. We have some ideas for Las Vegas, and are currently trying to figure out whether or not we want to go for something simple but cool like Circus Circus or whether funds will stretch to four nights at the Wynn Las Vegas or the Bellagio.

What we don't know about yet is New York and San Francisco. We'll be spending three nights in New York starting the week after the 4th of July weekend, and three nights in San Francisco over the second weekend in August. Has anyone out there got any good ideas for nice areas or hotels in New York and San Francisco?

One suggestion we're looking into for New York is not to stay in Manhattan - the person who made this suggestion to my friend was a little light on facts, but we think they might have been talking about staying in New Jersey and commuting in for sightseeing. Anyone out there think this would be a good idea? How long would it take to get in to the city each day?

(if it's helpful to know, at this point we might not have picked up our rental car, and would be using public transport to get around)

And how about San Francisco? Where's a good area to be looking for staying for in San Francisco? I should add, that we are looking for hotels/B&Bs rather than hostels; we're motelling it for most of the trip, so think that we can stay in hotels for NY, LV and SF - though of course, unless there are some very special offers, not in the likes of the Hilton!!!

(and on the motel front, what chains should we stay in?)

Any advice that anyone can offer would be very greatly appreciated!

Project Euler, Problem 27

Had a bit of a slump in doing these, as I had more or less reached the limit of what I could do with the skills that I had in C++. Then had a look back through the notes that I made about the problems that I was looking at, and noticed that there was one which I could probably work on further.

Problem 27
Euler published the remarkable quadratic formula n^2 + n + 41. It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39.
Using computers, the incredible formula n^2 − 79n + 1601 was discovered, which produces 80 primes for the consecutive values n = 0 to 79. The product of the coefficients, −79 and 1601, is −126479.
Considering quadratics of the form:
n^2 + an + b, where |a| <>
find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n = 0.

There's a lot of possible quadratic expressions to be considered for this, but a bit of thought soon lets you realise that b has to be positive, and has to be a prime. I had a reasonable suspicion as well that the magnitude of a has to be smaller than b, but I didn't put that in the routine that I put together.

After this it was just a case of putting something together that would check and see if the various expressions produced primes. I decided that putting in lots of loops and checks to find the expression that produced the longest sequence of primes was going to be quite time-consuming, so I started generating if statements to weed out those expressions which would be more likely to be the right answer (basically by looking at what elements generated primes for various values of n). Analysing the few that remained from this gave me the final answer.

Again, this one wasn't the most elegant solution, but it felt good to be using my analytical skills to do it rather than just brute-forcing something without any consideration.

Onwards and upwards!

Monday 2 February 2009

Update, Thing 33

As I noted recently, I realised that one of the things that I had listed was a duplicate! This left me with having to find something else cool and creative to do. This last week I've been looking over some old things that I've written (this is as I've been sorting out my room). I found some notes to do with my 2005 NaNoWriMo novel, and this got me thinking.

From 2006 I've written a novel every November that has been a complete story, but in 2005 I came very close. I got those 50,000 words written, but the story wasn't finished. I'll write a little bit some time soon about what the general plot was and the structure. One of my 101 things is to work on the novel from 2006, which I finished, and to redraft it and edit it - and now I think I am going to use my spare challenge (rising from the duplicate) to finish the novel from 2005. And not just finish it, but edit and redraft the parts that I had done. I'm not interested in just finishing the last few chapters unless I go back and work on the whole thing.

So there we go, thing number 33 in my list of 101 things is now:

33. Complete my NaNoWriMo novel from 2005.

That novel was set in Liverpool (more or less); just had a thought, might actually go out some time while I'm working on this - though not this week due to the snow! - and take some pictures in and around the suburbs of Liverpool and in the city, see if I can't get something there to help me with the mood of it.

Am I beginning to think like a proper writer???

Recent Books

For my birthday my sister got me the Nintendo DS application "100 Classic Novel Collection", which is something that I thought was quite exciting when I first heard about it just after Christmas. To give it a go I decided to re-read a novel that I thought was really interesting when I first read it a few years ago, The Picture of Dorian Gray by Oscar Wilde.

I'm not going to say too much about the novel itself - you should definitely check it out, whatever your views on classic literature, it's a fantastic story and really effective - but I wanted to say a word or two about the presentation medium. Given the price and restrictions of some ebook readers, it's quite nice to see something simple like this for the DS. A hundred novels (for around £15 if you shop online) all on a little cartridge and the interface is a piece of hardware that is relatively cheap compared to the current generation of electronic readers. The display isn't quite big enough, as even the smallest text it displays is quite narrow on the screen, almost like a newspaper column.

There's a big homebrew movement for the DS, so I'm sure there are people out there who have put together some kind of ebook reader, but this is something that Nintendo should definitely get on to - nevermind classic novels and plays (the application for the DS at the moment is a collection of out of copyright works), I want to be able to use my DS to read ebooks that I've downloaded, or even pdfs I've produced! Nintendo, get on to it!

From the library I got Something's Down There by Mickey Spillane; I got it in lieu of being able to get one of his Mike Hammer novels (I'll check the online catalogue soon, see if they have any). It was a pretty interesting thriller, as gritty as his Mike Hammer stuff, but I didn't find it quite as interesting as, say, My Gun Is Quick. Haven't read a good piece of noir for a while; I'm currently re-reading the complete Chronicles of Narnia, but think I will go looking for some more noir when I'm done with that, maybe something by Raymond Chandler.

Sunday 1 February 2009

Flash Fiction: The Lying Sister

The Lying Sister
Nathan Ryder

The Friends of the Forest hold a fair at Royden Park on the first Sunday of July every summer. My Mum always insisted that we go and do our bit to help with conservation.
I remember Royden Park being really big when I was a little boy. My older brother Tom thought it was boring, but apart from a bit of hay fever I was really happy that sunny Sunday afternoon. I was constantly distracted by clowns, coconut shies and donkey rides, and I wandered off, too young to know that there is any danger in the world for children. The field that hosts the fair is bounded by a thick line of trees on three sides, and I found myself peering into the trees, having run out of money playing the 'ball in the bucket to win' game.
Just as it was occurring to me that I was alone and didn't know where my family was, I heard a voice.
“Psst!”
I turned and looked among the trees, but saw nothing.
From straight in front of me I heard the same voice again: “Hi...”
It took me a few seconds, but then things seemed to come into focus, and I saw the outline of a little girl in front of me. It was as if the edge of her came from a pattern on tree bark, a flickering shadow from the breeze, and the subtle tones of green that made up the leaves on low hanging branches. I said hello back.
“Hi big brother,” she said, stepping forward slightly; as she moved the colours of the trees fell away from her, and there she was, a little girl, dressed simply in a pink dress, hair tied back smartly and a pleasant smile on her face.
“Oi! Billy!”
I turned and saw Tom running up to me. He was eleven, and his face was a mix of anger, boredom and smugness. It was an expression I recognised well.
“You little div!” he shouted at me, “Mum and Dad are looking everywhere for you, what are you doing?!”
I turned to point at the little girl, but she was gone, there was nobody there. I blinked, but didn't have time to think about it as Tom pushed me and told me off. By the time we got back to my parents, I had almost forgotten the little girl who came out of the trees. They were more relieved than angry, but it didn't stop Tom from being the golden boy for a few days.

I was ten the next time that I went back to the fair at Royden Park. Tom was old enough to get out of it by then. Royden Park was nowhere near as good as I remembered.
The vast expanse of green was just a small field, marked off with trees on three sides. Only one of those sides was really a forest, the others were just a thin line of trees and bushes separating it from other fields. The fair was rubbish too. I knew now that most of the games were just a con, even if I won a prize it wouldn't be worth the fifty pence I handed over to play.
Mum trusted me to wander off by myself and not get lost now. She still liked coming to the fair for the Friends of the Forest, she thought it was really important, said that the forest had a lot of history. I was wandering around the edge of the field trying to pass the time while Mum was off buying some handmade mirrors or bowls or whatever.
“Hi big brother.”
I turned to look at the treeline and a stray half-memory came to me as I saw the little girl standing before me, peering at me with curious green eyes.
“Who are you?” I asked.
“I'm your little sister,” she replied, smiling and winking at me in a manner that wasn't right for such a young child, “I'm your little sister... Sally. I'm five years old and I've lived with you ever since I was born.”
“No you're not,” I replied, wrinkling my nose up with contempt, “I've only got a big brother, Tom.”
“And, me, your little sister, Sally. Stop playing mean games... Billy,” she said, reaching out and trying to touch me. I stepped back to avoid her hand. I noticed then that she was... vague. I could see her, but around the edges she was less distinct, especially at the ends of her arms and legs.
“I don't know you,” I said, stepping back again and avoiding her grasp.
“You do too!” she screamed suddenly, lunging for me and grabbing my wrist. Her hand was warm, but I could see my arm through it as she held me in place. It was like a vice, and despite being a much larger child I couldn't pull free from it.
“Say you're my brother!” she spat out; her eyes were red around the edges, and her hair was no longer blonde but turning brown and green, woodland colours blending together. “Say you're my brother and I'll let you go you miserable pig!”
I called for help, but I was too far away from anyone, and she was impossibly strong.
“Let me go!” I shouted at her, finally resorting to hitting her; I brought my hand across her face, but it was like I had slapped a wall and I cringed with the pain.
“Say it!” she shrieked, and I felt her nails digging in to my arm.
“I'm your brother, Billy!” I shouted, and then shouted it again turning and screaming at her now mottled and dark features, cunning great green eyes that stare back into mine, satisfied. I lose myself in them, the pain fading.

“Mum!”
She can't hear you. No one can. Hmm, maybe a child could, but you're no more than a child yourself, which is why we need you...
I see my mother, frantic, looking for me.
She'll forget soon. We'll make her forget. You won't be missed. We're not cruel that way...
“Let me go! Please! MUM!”
I see her – but I don't know how – and she is less certain of what she is doing; a momentary panic that had her is fading; she reaches in to her handbag and takes out the car keys.
“MUM!”
A second of hesitation, and something like my heart dares to hope, but then she wanders off back to the car park. Time passes and I see the fairground people take their stalls down. I keep calling out, desperately hoping someone will hear me.
You'll get used to it, says the little girl's voice, I did. This is the way it is.
Time passes as in a dream. Water flows into me, and sunlight makes me dizzy with satisfaction. It is a long time before the others get through to me, and tell me what I have to do. They do what they must. I tell myself I will have no part of it, that I am still something else, that I'm not supposed to be here.
And then one day the fair comes to the park, and somehow I know what I will do, even before I see the child running around, coming closer and closer to the edge of treeline.
It isn't so bad here, reminds the voice of my lying sister, a voice that I now hate and love as kin. And it isn't. There is no other way. We all have to do our bit for the Friends of the Forest.

*
Creative Commons License
This short story is released under a Creative Commons Attribution-Noncommercial-No Derivative Works License. Feel free to repost and share it with others, so long as you credit me (Nathan Ryder, 2009) as the original author and link back to this page. It would also be nice if you dropped me a comment!

Flash Fiction: Nursery Noir

Nursery Noir
Nathan Ryder

I'm sat at my desk when the quiet's broken by a dame. I put down the blocks I'm building with – maybe a house, maybe a doggie, I haven't decided – and walk across the classroom.
My name is Jonah Jones, I'm three years, three months and some change old, and I'm a gumshoe.

Lisa's a sweet girl. Aside from wailing she isn't much for talking. I'm a sucker for a redhead though, and Lisa think she's a princess. I'm sure her parents do too. Go figure.
She's stood there next to the dress up corner, crying like a kid cutting her teeth. I have a quarter of a grape stuck behind my teeth, and I chew it over whilst standing there waiting for her to calm down. She's way too upset to get any sense out of, and I wouldn't expect miracles from a dame when she ain't crying.
My eyes wander and I notice the ripped princess costume in front of her. I stoop to grab it, feeling my pull-ups ride up. I smell something funny but I'm dry; it's early – not even milk time – and I'm usually fine but there's plenty of time for things to go wrong. I try to hand her the torn pink dress and she goes on crying even louder.
Then something goes wrong. I feel the hand of Miss on my shoulder, turn and knew I've been tapped as a fall guy.

Miss gives me a dressing down. I stand there and take it, mind elsewhere; my Mom's sure to hear about this.
Lisa isn't talking, can barely string a sentence together anyway. Maybe she doesn't know, but someone does. Someone's happy for me to take the fall. I might not be able to convince Miss, I might not be able to convince Lisa, but I will find the truth.
I vow that I'll find the rat and make him pay.
Then Miss puts me in Time Out. My investigation is on hold.

It feels like a week, but it's probably only five minutes. Still, I'm ready to snap by the time she lets me out to play with the paints. I stand at an easel and hold my arms out for Miss's Assistant to put an apron on me.
I begin to paint a picture of the crime.
Lisa's favourite dress has been ruined, torn almost in two. Miss has me collared for the job, and Lisa's unable to get me out of it because she's a big crybaby. Way I figure, it's a senseless crime, but who knows? The world is full of crazy broads and bastards (a bad word I heard my Daddy say) and none more so than in the Nursery.
Chubby Smith sidles up to to me and asks what all that was about. Nothing seems to get by Chubby, and for a minute I consider asking him if he saw anything. Information is never free from Chubby, I tell him to scram for now. He takes off smiling though, and I have a terrible feeling that I'm going to have to speak to him again before all this is over.

I'm trying to figure the angle, and have ended up with what I think is a nice picture of a tree, but it's no help. I go to see Mr Bear.
Sure, he's a big stuffed bear, but he usually helps. We talk for a while. Well, I talk, and he listens. I sit on top of one of his legs and look at his immobile face. I know he isn't real, and at the same time I know he's taking it all in.
I tell him everything, and just as I'm finishing I smell something funny again – not funny ha-ha either. I look up to see Stinky Tyler grinning at me. The smell from him takes my breath away for a second; realisation dawns as he speaks.
“Play time's over. Boss wants to seeya.”

Miss is the authority, but the Organisation is something else. I've known about them for a few weeks now, but never crossed paths with them directly. Before me now, hiding in plain sight, their Boss, Chubby Smith. Stinky Tyler's hand is on my shoulder as he leads me over to the sandbox.
“Can't have you talking Jonah,” says Chubby, studying the tower of a sandcastle.
“I had next to nothing until you and Stinky poked your beaks in,” I reply, looking around casually. All the guys I'd figure as bad apples in the class: Jimmy Crayons, Wet Tony, Wheezy Jackson.
“How about now?” asks Chubby as his eyes meet mine.
I shrug.
“A protection racket, right? You get 'donations' from other kids, their favourite things stay nice and unbroke.”
Chubby smiles.
“You're not so smart are you though Chubby?” He frowns and stands up.
“You didn't have Lisa figured as a screamer, did you Chubby?” I continue, “You knew she wouldn't talk – hell, she can't – but you didn't have a head for these hysterical dames.”
“And you, you stupid baby, you just wander in and start asking questions, thinking about things...” mutters Chubby as he signals his boys to come over.
I think fast; they'll work me over, nothing obvious, and I'll have to keep shtum.
Only one thing I can think of can get me out of this, even though it pains me to do it.
I'm a big kid now, but even big kids slip up. I let it go, and feel my pants filling and start to cry. For a second Chubby laughs, thinking that I'm not such a tough guy, but then as my wailing gets louder he wises up.
Too late.
Miss and the Classroom Assistant are there, just as I'm surrounded by these slightly bigger boys, my pants smelling ripe. There's a few explanations for the scene that they're seeing, but in all the obvious ones, I'm the victim.
I smile through my tears as Chubby starts getting told off.

Miss found other kids' toys and possessions hidden in the sandbox. They started asking questions and Chubby started crying. My guess is it'll be a long time before he even thinks about anything like that again.
Half an hour later I'm changed and back at my desk, trying to figure out from the blocks whether I was working on a house or a doggie. Neither makes much sense.
“Th-thank you.”
I look up and see Lisa smiling, standing awkwardly, shifting from one foot to the other. I wink at her and indicate the chair next to me, pushing half of the blocks in front of her place.
“You know doll,” I say, leaning back and grinning, “This could be the start of a beautiful friendship...”

*
Creative Commons License
This short story is released under a Creative Commons Attribution-Noncommercial-No Derivative Works License. Feel free to repost and share it with others, so long as you credit me (Nathan Ryder, 2009) as the original author and link back to this page. It would also be nice if you dropped me a comment!

V Day

Nope, not Victory or Valentine's, but Vegetarian. For the next month I'll not be eating meat or fish, see how it goes. I don't think I'll give up meat and fish after this, but I just thought it would be good to do this from time to time (for three months over the course of 101/1001). Kind of a detox, kind of encourages me to do something different.

I'm also hoping to eat my "five-a-day" every day for a month. I struggle with this quite a lot most of the time, not because I don't like fruit and veg (although I'm not that keen on most fruits if I'm honest), but because it just feels like there is only so much you can eat sometimes!

I'll be keeping a record of what I eat and the impact that this has on my health/weight as well. Another resolution for this month is to do at least a kilometre every day on my cross trainer (I should be able to do much more than that, but at the very least if I do that I will feel like I've done something). Am hoping that a combination of eating healthier and definitely doing more exercise will result in the start of weight loss and trimming down.

AND if all that wasn't enough, I'm going to start keeping a written diary as well (Thing 2). I used to keep a journal some years ago, and eventually fell out of the habit; I would write every morning and evening as I got the train over to uni. I now fill that time reading, and I like reading during that time, so I'm going to have to find time to keep my journal. Edited highlights will appear here over the coming months.

So, many beginnings today... Here's hoping that I see these things through to their conclusions!