Tuesday, 21 June 2022

How to write a character who is smarter than you

We all have that one character (or few) who is significantly smarter than the writer. So, as a writer, how do you write such a character convincingly?

I can't claim to give you a formula for this or an answer that works every time. However, I have a lot of experience writing precisely these types of characters. This is probably also true of other mystery writers in general. I will share a few of my favourite tricks for pulling off highly intelligent characters convincingly.

1. Make them smarter in different ways.

A good example of this is Cassie from the short stories I've published here. No, Cassie isn't really smarter than me, or at least, not in every way. She is also somewhat immature. However, she does have a significant edge over me in a few things.

She is more observant, and her recall is mostly flawless. She is also willing to work on something that might not be very useful for a long time.

The thing is, all of this are qualities that can be faked on the page (or even in a comic book format) quite easily. As the writer, you will know which details are important and which details aren't, but the thing is, neither your characters nor your readers will have that knowledge. So when your character notices random things all the time, neither they nor the audience will know which of these are more important. You can also do this with details in the background for a visual medium. As long as you remember to put these details in / make it reasonably likely that your character observed them.

Then, when your character actually recalls the relevant information, it can look, well, impressive.

Of course, you can come up with other characteristics like this. A photographic memory helps. A character who observes people for fun will notice more than your average person. Depending on the genre you're writing, the characteristics that are useful will change.

2. Work backwards.

This can be a hit or a miss. 

If you know the ending, you're working with more context than your average character or reader. Therefore, your deductions, etc. will be more accurate. Having your character make these deductions would make them look really smart.

However, this is also very easy to mess up. First of all, you have to make sure that your character has all the information needed to make the particular deduction. You also have to be aware of the fact that the same information may be interpreted in different ways, so having your character acknowledge other possibilities would be a good idea. The problem here is that it's very easy to develop tunnel vision when writing something like this and completely fail to see alternative theories. 

Alpha readers and time can be your friends here. You can wait until you've forgotten the details of the story partially, but it can be a bit inconvenient, especially if you're a pantser like me (i.e. coming back and realising there's another possible explanation that your detective would have run with). Alpha readers are hard to come by. I really don't have an easy answer for this.

So what happens if you mess this up? The result is an explanation / deduction / theory that your character pulled out of their rear end. Or at least, that's what your readers will think. This will break your immersion completely, so use with caution.

In short, this is a high risk, high reward strategy.

3. Time is your friend.

You have hours to days to write or plan what your character must execute in minutes. Use that to your advantage. 

Your character may not have the luxury to document everything in the heat of the moment to discover patterns. You do. They may not have a full plan of their location. You can draw one and then sketch your plan there. They can't sleep on the problem, you can.

Once you've done that, have your character do all of that with less time / resources / etc. and they will look extremely smart. Of course, you should work with the information that the character would know or have a reasonable chance of knowing, otherwise you will risk breaking immersion.

4. Contrast

Contrasting your character against someone who isn't as smart is another good way to make them look intelligent. People generally interpret things relative to what's around it, so this can make your character look more intelligent by comparison. This is basically the Dr Watson to your Sherlock Holmes. 

So what if you have a lot of intelligent characters? Well, you can make them intelligent in different ways, which maintains the contrast, but highlights each character's capabilities relative to the others. This is especially useful if you have an ensemble cast, where everyone's supposed to be smart.

5. Have other characters tell the reader that a particular character is smart

This, admittedly, is a bit of a sneaky strategy and one that has to be used sparingly. You will also have to back this up with some proof occasionally. However, having other characters tell the reader that a character is intelligent (and treat them that way), particularly at their introduction, is a good way to form a particular impression in the minds of your readers.

However, you will have to back this up, especially if your character appears with any frequency or has an important role in the story. Otherwise, it will make the rest of your characters look less intelligent and possibly make the whole story frustrating. 

The advantage here is that you can take your time with showing your character's smarts. For example, you can introduce a character and then take your time with having them do something significant and smart. This will also come off an a payoff of a previous setup, which makes it even more satisfying.

6. Have your character's intelligence be of the sort that doesn't have to be demonstrated on the page

This is a fairly common approach, especially with scientist type characters. You can simply have them come up with gadgets, etc. with no explanation about how it was done, because frankly, most readers aren't interested in that. You can also add in a little technobabble to make it sound more convincing. 

This works, but I don't like this approach very much. Bad technobabble can be off-putting (I can't remember the number of times I've had to scream internally because they got the physics / engineering so wrong). 

A better approach would be to research the subject in question a little. You don't have to understand the maths (because you will have to deal with maths if you're going to study it in depth), but as long as you understand the general theory or study how experts talk about the subject to other people, you should have a reasonable starting point. Then you can go ahead and write about someone who created a supercar or space station without having to design one yourself.

Closing thoughts

These are not the only tricks you can use. If you have any, please put it in the comments! I'd love to hear about it and maybe have a discussion. 

Not all the tricks mentioned here are equally successful, and not all of them work for every intelligent character. You will have to decide what works for you (I know I say this in every writing related post but it's true). 

Hope this helps, and see you next time!

You can follow me on Facebook here and twitter here for updates.

Monday, 20 June 2022

The man in black - chapter 4 (short story)

  chapter 1 | chapter 2 | chapter 3

“That wasn’t much use, was it?” asked Anna, “purple shirt? Seriously?”

“No, we know all we need to know,” said Cassie.

Everyone looked up at her. Cassie did like showing off, but she did not enjoy the feeling of having everyone stare at her.

“What do you mean?” asked Selene.

“First, the video. Look at the video. There’s an important clue there.”

Selene took her phone out and looked at the video. Anna also looked at it over her shoulder.

“What do you mean?”

“The shoes, but also, he’s left-handed,” said Cassie, “at least, that’s likely. Sure, he’s holding the board in his right, and slings his bag over his right shoulder, but you’d think he’d grab something like a pistol with the hand he’s more used to.”

“Not necessarily,” said Selene, “I prefer using my left hand too, but that’s because I draw a lot and I want to protect my right hand.”

Cassie digested this information. “Okay, but there’s another clue. He nearly crashed into stuff three times over about 150 m.”

“In a crowded mall,” said Lex.

“But did you crash into stuff?”

“Nah, but we were slowed by, you know, trying to avoid the debris.”

“Run that distance now. The mall is more crowded than it was then,” said Cassie.

“Fine. Stay out of the way,” said Lex.

He walked back to the coffee shop, and then started running towards the bathroom. He ran past them at full speed, nearly ran into someone coming out of a shop, and then reached the bathrooms.

“Well?” asked Cassie.

“Depth perception? That’s what you’re trying to say, right?” asked Selene.

“Yup. The guy wears glasses, and they’re probably fairly powerful,” said Cassie, “you may not have realised it, but they can really mess with depth perception if you’re used to wearing them and then take them off. None of the men had sunglasses, and they couldn’t use those with a prescription because the lens power would give them away immediately.”

“Possible,” said Selene, “But the artist guy was the only one wearing a shirt, and he wasn’t wearing glasses. That’s not accounting for the colours of what they were wearing. What about the purple shirt?”

“Let’s go back to the shop,” said Cassie, “well, you probably already know where this is going, but let’s ask them ourselves.”

Lex joined them as they entered the shop. The woman who talked to them was at the entrance.

“Could you tell us where you were when you saw the robber run past?” asked Selene.

“Inside the shop,” she said, “come on in, I’ll show you. I was standing right here, hanging the new earphones that had come in when I heard the noise. I turned and saw him run past. He was starting to open the coat as he ran.”

“Preparing to dump it once he reached the bathroom, I suspect,” said Selene, walked up to where she was, “so… wow!”

“Oh!” said Dany, “The lights at the entrance. They flash red, blue, green and yellow, and it would hit anyone near the boxes.”

“And if it was flashing red, a light blue shirt would look purple. Neither beige nor grey would look purple under any of the colours. So, why did you say it was a shirt?” asked Selene.

The woman looked mystified.

“It was a t-shirt with a collar, I think. I didn’t see it very clearly, but the way the collar sat was a bit like what she’s wearing.”

She indicated Cassie. Cassie was wearing a black t-shirt that fit that description. Her collar was a mess, with one side sitting higher than the other. Cassie knew from experience that shirt collars, especially those made of materials that men’s shirts were usually made of, didn’t do that unless someone wanted them to look that way.

“Then we have a suspect,” said Selene, “good job noticing it, Cassie. Let’s go ask him.”

They returned to where Mark was, along with the suspects.

“We have three new witness statements. One, that the perpetrator nearly crashed into a pile of books, then into a customer, and then a box of cables. Two, we know that he was wearing a t-shirt with a collar that was bluish. Three, we know from the statements from everyone who saw the robbery that he was wearing black leather shoes. That means we have enough circumstantial evidence against Hal.”

Mark looked at Selene. He took a minute to process what was being said. In the meantime, Hal stood up.

“That doesn’t prove anything! First of all, how did you know that the guy you’re looking for went in here?”

“Judging by how the door slammed, I suspect they heard you,” said Adam.

“Both of us saw you,” said Bella, “if you’re sure you’re innocent, let them test the money you have for fingerprints. That shouldn’t be too hard, should it?”

“Of course Liv’s fingerprints would be on it!” said Hal, “I go to that café whenever I come here, so…”

“Not hers,” said Cassie, “we’re talking about the two that paid for that huge order.”

“Exactly,” said Selene, “or you have an excuse for that as well?”

“I know them alright,” said Hal, “they’re from the newspaper office. They’re having a bit of a get together today. I recommended the shop to them. Their fingerprints could also be there.”

“They pay you in cash?” asked Darrell, “that’s funny. I would have thought cheque, or a direct funds transfer to your account would have been more, well, normal.”

“Besides, even if they paid in cash, it’s unlikely that both sets of fingerprints would be on the same notes,” said Mark, standing up, “so I guess we’ll figure it out. Come with us to the police station. We’ll know soon enough.”

Then a security guard came up to them.

“They found a black bag, a pair of sunglasses, a toy pistol, and a pair of black track pants on the ground outside the mall building. It looks like it fell from one of the ventilation windows on the toilets from one of the upper floors, including this one. The pistol was cracked open. I told them to not touch anything.”

“What about the gloves and mask?” asked Lex.

“In the toilet?” asked Cassie.

“We’re going to have to search the toilet then,” said Mark, “but there should be evidence we can use in the hat, and possibly the glasses. You’re under arrest for armed robbery.”

Hal knew the game was up, and he didn’t really resist after that. Selene called for more help to deal with the evidence. They showed up some time later. Then Selene took their statements. They barely made it in time for the movie.

Next morning, Cassie ran into Anna at the convenience store. There, she updated her about the situation. Hal’s hair had been found in the hat. They found nothing on the pistol or sunglasses. He also had a lot of cash, they found notes with Liv’s fingerprints, which also had fingerprints from the two at the newspaper office. Hal had confessed when presented with all this evidence. Cassie waited until Anna was done.

“So, do you know the motive?” asked Cassie, “and why the coffee shop?”

“Money,” said Anna, “apparently the newspaper office didn’t pay him in time, so he decided to take matters into his own hands.”

“He robbed the coffee shop.”

Anna shrugged. “If you read his articles, you’d know he’s not that smart. So, when’s your flight?”

“Five hours. The taxi should be here in half an hour.”

“See you in two weeks then.”

Cassie said goodbye to Anna. The case was done. Now, she just had to look forward to the holidays.


This is the second chapter uploaded today, so if you missed chapter 3, please check it out below.

Previous chapters: chapter 1 | chapter 2 | chapter 3

You can also follow me on Facebook here.

I don't have another short story in the pipeline just yet (and no time for it right now, honestly), but I'll try to get another out in maybe a month? No guarantees though.

Until next time!

The man in black - chapter 3 (short story)

 chapter 1 | chapter 2 | chapter 4

Selene sat the three men down on a bench.

“Okay, let’s start with Darrell. Tell me what you’ve been doing today.”

“I woke at around two in the afternoon. Then I worked on a painting, started another, and then remembered a commission I was supposed to do, tried to start on that, realised I didn’t have the colours I wanted, came here to shop, the shop told me they didn’t have the paints but their supplies would be coming in a little later. So I visited a few other shops, and walked to the gallery upstairs, hung around there, talked with the people there for a while, browsed the bookshop – you know, the usual.”

Cassie didn’t know whether she was worried about him or for him. Still, the story made some sense. Possibly.

“Okay, Hal?” asked Selene.

“Did some writing, watched some stuff because I couldn’t concentrate, and then realised I needed new headphones. I was also browsing for a pen drive and maybe a good keyboard, but I didn’t find anything I really liked. Other than that, I’ve also been looking for a microphone, but again, I didn’t really find anything.”

“I thought you were a writer?”

Hal shrugged. “I was thinking of doing some instructional videos online, and I have a face fit for radio.”

“That’s why you weren’t looking for a camera?” asked Darrell.


Cassie didn’t think he needed to worry about it that much. Maybe he was just shy.

“Then, Adam?”

“I’ve been here since morning, except for the times I was drinking copious amounts of coffee at Ed’s shop. Mostly at the repair shop, actually. Seriously though, if I wanted to rob a shop here, I’d start with our cash register. The stuff we sell are usually more expensive, you know.”

“But don’t most people pay using cards?” asked Phil.

“Not always,” said Adam.

“Yeah, who’d rob a coffee shop?” asked Darrell, “there are three bank branches, a few shops selling extremely expensive clothes and stuff, a few expensive restaurants, several shops selling phones, phone accessories and computer accessories, a couple of shops selling actual computers, cosmetics shops, at least three fast food restaurants, and probably many others. Why would anyone target a small coffee shop?”

“They had a pretty big order today,” said Cassie, “and they paid for it in cash. Someone probably knew about it in advance.”

“Internal information?” asked Selene, “interesting. So, anyway, this would be a lot simpler if one of you could confess. So, did any of you do it, and could you tell me the approximate amount that was stolen if that is the case?”

The three men looked at each other. All of them shook their heads. Selene sighed.

“Guess we’ll have to do this the hard way then. You know we’re going to find out, right?”

The other policeman, Mark, returned just then. Cassie noticed that Liv and Ed weren’t with him.

“It appears all three visit the shop often enough to be remembered,” said Mark, “They knew Adam very well, and apparently the other two visit the shop regularly as well, though they didn’t know their names and occupations for sure.”

That makes sense, thought Cassie. Hence the whole communicating with boards thing – he didn’t want anyone to hear his voice.

Selene turned to Mark. “Could you take over here? I’m going to go look for eyewitnesses.”


Selene turned to them. “Anna, coming?”

Anna nodded. “Sure, sis. Cassie, Dany, Phil, are you coming too? They’re great at noticing stuff.”

Selene looked at Cassie. “Sure. Come along then. Who chased the perp to the bathroom?”

“Bella and Lex,” said Cassie, “it’s a good idea if one of them tag along as well.”

“Yeah, I’ll stay,” said Phil, “I forwarded it to Dany and Cassie, but I have to show it to Mark as well.”

Cassie nodded. Selene looked mystified. Cassie looked in her messages, found the video, and forwarded it to Anna, as they set off. Lex joined them, as Bella would be more useful in a fight.

Anna got the message and forwarded it to Selene. “Sent you the video, sis. Phil videoed the guy robbing the shop.”

Selene was her sister? Cassie had never heard of it, but then again, the two of them rarely talked about their families.

“That’s what you were talking about,” said Selene, “I’ll take a look at that. So, he ran through here?”

“Positive,” said Lex, “Dude crashed straight into a bunch of cables in boxes around here, about landed on his face, but he didn’t actually fall. The cables weren’t that lucky.”

“Let’s ask the people in the shop then,” said Selene.

She walked in and talked to the two women who worked in the shop. As it turned out, one was busy with a customer and didn’t see what happened, but the other saw the incident clearly.

“He straight up kicked the box, and almost fell on his face because of that. I think we’ll be digging cables out from here for the next millennium. Anyway, I didn’t see a lot, except for him being about average height, dressed in all black except for a light purple shirt. Then he and a girl came running after him.”

Selene tried to press her for but details, but that was all she could say for sure. None of the men had been wearing a light purple shirt.

The next shop Lex indicated was a music shop, where the perp had narrowly avoided a collision with a customer. Selene went inside and talked to the owner of the shop. Cassie followed her in again.

All they got this time was that the man was definitely wearing something light coloured with a collar, which fit all three men.

Next, they stopped at the bookshop, where the cashier confirmed she had seen the chase, but couldn’t describe the man at all other than say he narrowly avoided falling on his face due to almost running into a stack of books on a low table. He did manage to knock a few of it to the ground.

The whole distance was maybe 150 m. They talked to several other shops as well, but they didn’t know much more about the man. Finally, the five of them stopped near the music shop.


Sorry for the delay! Things happened and updating this sort of slipped my mind. 

I will upload two chapters today (this and the final chapter).

Previous chapters: chapter 1 | chapter 2 

Next chapter: chapter 4

You can also follow me on Facebook here.

Until next time!

Sunday, 1 May 2022

The man in black - chapter 2 (short story)

chapter 1 | chapter 3 | chapter 4

There was no doubt about it, this was a robbery. Jake appeared to have noticed what was going on as well, but Dany held his hand. He stopped. Lex and Bella stopped their discussion immediately. Cassie remembered that Bella was a bit serious about martial arts. Would she attack? Cassie didn’t know a lot about fighting, but the chairs were light, and she could use it as an emergency weapon if she had to be Bella’s backup.

Bella stood up. “Hey, is everything alright over there?” she asked.

The robber turned and pointed a pistol at them, while keeping the cashier in range as well. Cassie also saw the paper.

“Put all your money into the bag. Do not call the police.”

Pretty brazen, pulling this off in the middle of a crowded mall. All the cashier had to do was to stall. Someone would walk in. Unfortunately, the inside of the shop was not visible from all sides of the shop, due to a sticker on the glass, though they could see everything on the outside. There were also no cameras inside the shop.

The cashier continued stuffing the cash in the register into the bag. The waiter was also frozen on the other side of the counter. The robber folded the paper in two with one hand, displaying the message ‘hurry up’.

Was the pistol real? Cassie couldn’t tell – she had never seen a real one up close, and she suspected it was the same for the others with her. She didn’t dare move. The cashier finished stuffing all the money from the cash register into the bag. The robber grabbed the bag with one hand and backed out slowly, still aiming the pistol at them. Then, the robber turned and ran, straight through the mall.

Lex recovered first.

“After him!”

A look passed between him and Cassie. Both understood. Lex ran after the robber. Bella followed. Anna immediately placed a call to the police, as she was the only person from around there. Cassie walked up to the cashier. She had collapsed back into her chair. She looked shaken, but Cassie couldn’t afford to dawdle.

“Do you know who that was?”

The cashier shook her head. The waiter was also trying to take a call. Phil took his phone out of his shirt pocket. That was when Cassie noticed what he had done.

“Can you identify the guy?” asked Dany.

“I don’t think so,” said Phil, “you might be able to work out his skin tone around his ears and neck, but that’s about it.”

“Wasn’t wearing earrings,” said Cassie, “that might be useful. About average skin tone, couldn’t see whatever they were wearing under the coat, probably a man because those shoes would be odd on a woman, trousers were surprisingly baggy – will probably be thrown out. Average or slim build – hard to say. Height’s about 170 cm unless they were wearing lifts in their shoes. Did anyone smell perfume? Or deodorant or aftershave?”

Cassie looked at the cashier. She shook her head. That wasn't surprising, as most people wouldn't notice that unless the smell was offensive or they were wearing too much of it.

“The police is on the way,” said Anna.

Then Cassie’s phone rang. It was Lex. She answered.

“We chased him into the men’s bathroom,” said Lex, “I ran in, but dude had disappeared into a stall. The coat is on the floor, as is the hat. I don’t know which stall he ran into, but three stalls are occupied.”

“Where’s Bella?”

“She’s outside. She can’t come in here, can she?”

“Good point. The police are on the way, so try to hold them there. And stand guard outside the door because you won't stand a chance if it's not a one man job. We’ll join you as well.”

“I was about to do that. Bring the waiter or something. No one’s going to take a bunch of foreigners seriously.”

“Good point.”

Cassie, Jake, Dany, and Phil ended up leaving for the bathroom with the waiter, leaving just Anna and the cashier in the shop. The cashier agreed to close the shop immediately.

It took them a couple of minutes to get there. Bella was waiting outside, directing people away from the bathroom. Clearly, she wasn’t doing a good job of it. The waiter intervened immediately. Then a security guard joined them and helped them out once the waiter explained the situation. Jake and Lex went inside. The rest of them waited outside and kept others away from the scene. They heard arguing from the inside. The waiter went in as well. Cassie figured they were trying to detain those inside.

That was when the police arrived, along with Anna and the cashier. A police officer went inside immediately, and another, a woman, listened to their version of the story. Then the other policeman came out with three men in tow.

Two were wearing the same sort of shoes as the robber, Cassie noticed. Cassie didn’t think anyone would have a change of shoes with them. Shoes would be too bulky to hide under someone’s coat. If it had been in the bag, the cashier would have noticed it. It could have been hidden in the bathroom, but disposing of it once used would have been a problem.

Cassie also noticed that none of the men were dressed like the robber. Sure, the hat and coat were discarded. The gloves and mask could have been cut up and flushed. That was possible with the bag as well, as it was a drawstring bag. The trousers – well, that would be on the possible side, as they didn’t look too thick either. It would be more difficult to flush the sunglasses. There was a problem with this strategy though, as Cassie was sure that flushing that much fabric would create an epic clogging problem.

So where were the rest of the clothes?

There was another problem. Build and height wise, any of these three men could have been the robber. Cassie had hoped that would give the robber away immediately, but clearly, they had no such luck.

The policeman asked the security guard to lock that bathroom. Then he turned to the cashier.

“I’m Mark. Can you tell me your name?”

“Liv,” she answered.

“Alright, let’s go talk somewhere else. You too, Ed.”

The two employees of the shop followed him away. The other officer turned to the three suspects.

“Alright. Let’s go sit on a bench over there. Please tell me all about yourselves. I’m Selene, by the way.”

The first to speak was a man of about average height, wearing a beige short-sleeved shirt and a dull green cap./

“Darrell. I’m a painter, here to buy supplies. I’m not very successful or well known.”

The next to speak looked almost like a teenager. He was wearing a grey polo shirt, blue jeans, a baseball cap and fairly plain sneakers. He also wore glasses, but they didn’t look too powerful. Cassie couldn’t help noticing the dark circles under his eyes.

“Adam. I work at the laptop repair shop that’s over there.”

Looking at him more closely, Cassie judged it was likely. He was the sort of guy who didn’t really look his age. Or maybe he really was barely older than a teenager but a genius with laptop repairs.

The last to speak was wearing a light polo shirt and black jeans. He, too, wore glasses.

“Hal. I’m a freelance writer. I’m moderately successful. I mostly write online.”

Cassie could see they had their work cut out for them. All three men had the same height and build. All three had short black hair. All three had about the same skin tone. Their voices were different, but the robber hadn’t said a word during the robbery. And if their shirts were seen by an eyewitness, well, their shirts were about the same colour too.


Previous chapter: chapter 1

Next chapters: chapter 3 | chapter 4

You can also follow me on Facebook here.

Until next time!

Sunday, 24 April 2022

The man in black - chapter 1 (short story)

chapter 2 | chapter 3 | chapter 4

Cassie laughed.

“Yeah, that’s the most likely answer!”

“Sure, laugh!” said Anna, “I’m not sure it was technically in the syllabus!”

Cassie was in a small café in the mall near their university. The semester was over, and many of them would be heading home for the next month. That is why they had gone there for a movie, some gift shopping, and to have some fun with friends before that.

“Can we talk about something that’s, you know, not subject related?” asked Jake, “for example, which film are we watching?”

“There are a few good options,” said Dany, Jake’s girlfriend and newest addition to their group, “Okay, two as far as I am concerned. What about the rest of you?”

Phil had the website of the theatre up on his phone. “Boring romance, comedy, with huge inverted commas around 'comedy', not in English, not in English, superhero, action movie, and super serious awards bait. Dany’s right, there are only two options.”

“You can go watch the awards bait,” said Lex, “it might help you catch up on some sleep.”

“Very funny,” said Phil, “seriously, which one shall we watch?”

Cassie noticed a huge stack of boxes at the counter of the coffee shop. Probably some sort of order, she thought. There were two employees in the shop, and they were stacking it there. Cassie expected someone would come pick it up.

By now, the shop was almost empty except for them. That was no wonder, as they were a little past teatime. Most people would start having dinner. Cassie wondered who would be ordering stuff from a café at this time. Maybe it was for a party. That sort of made sense, especially if they’d be having dinner at late at night.

Anna sipped her coffee. “Let’s pick one when we get there. What do we do about food? Smuggle it in, or buy popcorn?”

“Eat once it’s over?” asked Dany, “it’s less illegal, somehow. They don’t want you smuggling food it because it stinks.”

“She’s got a point,” said Phil, “but I’m not buying popcorn. Seriously, why isn’t this a watch party at one of our rooms again?”

“Never occurred to anyone?” asked Cassie.

A pair of men came into the café. Cassie noticed they were dressed somewhat formally, but fancily. It was a party, probably some sort of minor cooperate event, thought Cassie. They started talking with the cashier. The waiter went out to get a trolley. Cassie could see why that would be needed. The car park was not that far away, but it was a lot of boxes.

“Let’s have a bit of a snack before the movie starts,” said Phil, “we have at least an hour to kill as it stands because someone’s idea of shopping was, well, strangely efficient.”

“I don’t like shopping, that’s why I made a list,” said Dany.

“Not judging you. Just an observation.”

“So, order some sandwiches?” asked Jake.

They all looked at each other, and a few of them nodded. Jake went up to the counter and placed the order. Just then, the waiter returned with a trolley. Cassie admired his self-control. She would have used it as a skateboard.

Both employees and the two men who came with them were kept busy filling up the trolley. The seven of them sipped their drinks slowly, trying to decide on a film, which then drifted into debate/ discussion about a previous film. Cassie hadn’t watched it, so she let Phil, Lex, and Bella debate it. The trolley was filled up, the men paid in cash, and they wheeled the trolley out. The waiter followed them, presumably to help them load it into a vehicle.

The waiter returned a few minutes later. He collapsed on a chair behind the counter. The cashier went into the kitchen. Cassie assumed it was to make the sandwiches they had ordered.

Outside, the mall was fairly crowded. The shop was a little glass island in the middle of the mall. There was a speciality food shop a little way away. It was way out of their price range. There was a couple of branded clothes shops. There was also a bookshop. Cassie wanted to go in there, in a way, but buying physical books didn’t make a lot of sense given her current living situation.

Cassie had her work cut out for her over the break. She had decided to go home for two weeks. The air ticket was expensive, but she wouldn’t have a chance to go home over the next summer because of her internship, which meant it was now or never. Going home would probably mean a trip, lots of food, and buying lots of stuff to bring back. On the other hand, she would not get any work done during that time, and she really wanted to practice what she had learned that semester, at least to stay in touch with things.

She had her sandwich mostly in silence as the discussion turned into a full-blown debate between Bella and Lex. She spent her time studying those around her. The couple sitting at the next table sat up. They finished and then paid the bill. They were dressed well. Possibly a date, Cassie decided. There was another man sitting alone at a table, staring at his phone and inhaling coffee. He wouldn’t be there long either, thought Cassie. He desperately needed to be awake for something, probably work of some sort given how he was scrolling through something on his phone.

The man stood up, as Bella launched into a tirade about a scene in the film they were talking about and how it illustrated her point. He paid the bill, and left. Their group was the only one left in the café. It wasn’t an issue, as there was a couple of hours to the displayed closing time.

Then someone walked in. Cassie sat up immediately. This person was wearing a long coat – a weird choice given the climate – as well as a black hat and a black mask, with dark sunglasses. They were also carrying a plain black drawstring bag and wearing gloves. Cassie couldn’t tell anything more about them other than their height – roughly in the 170 cm range – and the fact that they were wearing regular shoes most men would wear to work. Also, their hair was black and a little longer than shoulder length, but that was likely a wig.

Cassie stiffened. She nudged Dany, who was seated next to her. Phil, too appeared to have noticed what was happening.

Then, this person unfolded a piece of paper from their coat pocket and displayed it to the cashier. Cassie noticed her eyes widen.

Cassie realized it immediately – the shop was being robbed, and they were in the way if anything were to happen.


Next chapter: chapter 2 | chapter 3 | chapter 4

You can also follow me on Facebook here.

Until next time!

Sunday, 17 April 2022

A simple cipher with randomness to deter breaking it - The cipher used in The Cipher (short story)

This is the code used in The Cipher (short story) which was published in this blog. It is a very simple cipher. You can read the story in question here: chapter 1  | chapter 2 |  chapter 3 | chapter 4

Hopefully, this is a fun coding exercise for you.

To cipher:

  1. You can use only letters and space. Any other characters will have to be changed into these (or the code changed to accommodate them, which is trivial).
  2. Take the plaintext one letter at a time. Convert it to a number (A-Z corresponding to 0-25, space = 26).
  3. Generate a random single byte hexadecimal number
  4. Generate a second number so that the modulus 27 of the sum of the two numbers gives the number that corresponds to the character you want to cipher. Mathematically: (random_number_1 + random_number_2) mod 27 = the numerical equivalent of the character to want to encipher. We'll see the detail of the maths in the code below.
  5. That is your ciphertext. Repeat for every letter in the cipher.

A graphical representation of the enciphering method mentioned above.

To decipher:

  1. Take two hexadecimal numbers out of the cipher (four characters, break it into blocks of two characters each)
  2. convert them to the usual denary numbers
  3. Add the numbers, take the modulus 27 of the sum
  4. Match to corresponding letter / space
  5. This is your plaintext. Repeat through the entire ciphertext.

A graphical representation of the deciphering algorithm above.

The code:

The code is given in Java this time. Converting it to C++ is easy, as all the methods used are static, so you can put everything into one file without issue. Alternatively, you can call the method from another class as well. Either way should work.

Class Cipher:

This class handles the basic cipher operations. It accepts a line of ciphered text and deciphers it, or vice versa. I have left all the functions public, but it is not necessary. You can leave just the cipherLine and decipherLine methods public and make the rest private, it should work just fine.

I've also made all the functions static. You can go ahead and make the class static as well, because you really don't need to instantiate it. Alternatively, you could remove the static keyword from all the methods and use an instance of the class Cipher in main, but it's pointless as there is no need to instantiate it.

import java.util.Random;

public class Cipher {
private static Random rd = new Random();

//To store alphabet of cipher
private static char[] letters1 = {'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '};
//To store alphabet, lower case. The cipher can translate from upper case or
//lower case as programmed, but the deciphered result will be upper case.
private static char[] letters2 = {'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' '};

Ciphers a line of plaintext.
Returns the ciphered line.
public static String cipherLine(String line){
String ciphered = "";
for (int i = 0; i<line.length(); i++){
ciphered = ciphered+encipher(line.charAt(i));
return ciphered;

Ciphers a single character
Returns the ciphered equivalent of the character
public static String encipher(char letter){
String ciphered = "";
int num = 0;
int rem1 = 0;

//get equivalent numerical value
num = mapNum(letter);

//If number isn't mapped, that character is skipped over.
if ((num>26)||(num<0)){
ciphered = "";
System.out.println("invalid input");
return ciphered;

//Generates the two numbers whose sum produces the modulus 27 value we want.
//If you want an alphabet with over 27 characters, you can replace the value here.
int num1, num2 = 0;
num1 = rd.nextInt(256);
rem1 = num1%27;
if (num>rem1){
num2 = ((rd.nextInt(8)*27+(num-rem1)));
else if (num==rem1){
num2 = ((rd.nextInt(8)*27));
num2 = ((rd.nextInt(7)*27+(27-rem1)+num));

String temp1, temp2;
temp1 = Integer.toHexString(num1); //Convert to hex
if (temp1.length()==1) temp1 = "0"+temp1; //Pad if it is not two characters
temp2 = Integer.toHexString(num2);
if (temp2.length()==1) temp2 = "0"+temp2;

ciphered = temp1+temp2;

return ciphered;

Maps a letter to a corresponding number (index of array).
Works with both upper and lower case characters.
Returns corresponding number.
public static int mapNum (char letter){
int num = 0;
for (int i =0; i<27; i++){
if ((letter==letters1[i])||(letter==letters2[i])){
num = i;
num = 28;

return num;

Deciphers a line of enciphered text.
Returns the plaintext of that line.
public static String decipherLine(String line){
String deciphered = "";
char letter ='0';
for (int i = 0; i<(line.length()/4); i++){
letter = decipher(line.substring(4*i, 4*(i+1)));
deciphered = deciphered+letter;
return deciphered;

Deciphers a pair of hexadecimal numbers (or four characters).
Returns one plaintext characters.
public static char decipher (String letters){
int num,num1,num2 = 0;
char letter;
if (letters.length()!=4){
System.out.println("wrong length for character" + letters);
return '0';
String temp1 = letters.substring(0,2);
String temp2 = letters.substring(2,4);

num1 = Integer.parseInt(temp1,16);
num2 = Integer.parseInt(temp2,16);

num = (num1+num2)%27;

letter = mapChar(num);

return letter;

Maps a number to a character. Simply look up value in array if within range.
Returns character corresponding to number.
public static char mapChar(int num){
char letter = '0';
if ((num<0)||(num>26)){
System.out.println("Invalid number");
return letter;
letter = letters1[num];
return letter;

The breakdown:

Importing Random: because we're using random numbers to add a level of randomness when we're enciphering it.

Then within the class, random is initialised. 

The two arrays letters1 and letters2 are used to store the letters / characters used in the cipher.

Function cipherLine takes in one line of text, extracts a character from it at a time, and enciphers it.

The function encipher takes in a character sent to it by cipherLine, and ciphers it. This is where bulk of the processing happens. First, the number corresponding to the letter is obtained from mapNum. Then the return value is checked, and if it is not in range, the character is simply not ciphered. If it is in range (0-26 for mod 27, for 27 characters in the alphabet (letters + space)) Then it proceeds to generated the ciphered values.

This is done by generating a random number under 256 (as we want it to fit to 8 bits or two hexadecimal characters). This is the first number, num1 . The next part is generating the second number (num2) so that you get the required result by (num1 + num2) mod 27. This also includes a random component. Random numbers from 0-7 are used because 0 to 7*27 is 0 to 189, which will keep you just below the ceiling of 255 even if you add 27 to it.

The calculation basically is,

  1. First, calculate first number (num1in the code) modulus 27. rem = num1 mod 27. This value is used in the next part of the calculation.
  2. Then compare it with the remainder you need, i.e., the value that mapNum gave you. This is called num in the code.
  3. If rem is greater, simply calculate the difference (rem - num). Tack that on top of an integer multiple of 27 (the integer 0-7 generated randomly, multiplied by 27) and assign it to num2, you're good to go. In equation form: num2 = (random integer * 27) + (rem - num).
  4. If the two are equal, simply assign an integer multiple of 27 to num2. That is, num2 = (random integer * 27).
  5. If num is greater, calculate (27 - rem) + num, add that to an integer multiple of 27. However, note that you can't use a multiple of 7 here, as you may go over 255 in that case. That is why 0 to 6 is used. In equation form: num2 = (random integer *27) + (27 - rem) + num.

Once this is done, you have two numbers under 255, whose sum mod 27 gives you the index of your plaintext. These numbers are still integers, so the function Integer.toHexString() is used to convert it to a hexadecimal number. Note that the output is a string and not a number, which is actually convenient for us.

Next you have to check whether it's a single character, and if that's the case, you need to pad it with a zero, otherwise it'll affect the length of our string. This is the set of four characters is returned.

The next function mapNum is also fairly straightforward. You check whether the character you want is in the alphabet. If it is, return its index, if not, return 28 which the function encipher reads as an error.

Next we get to the functions related to deciphering.

decipherLine takes a string, and feeds four characters into the decipher function at a time. I used substring to do this. 

decipher is the function where most of the calculation takes place here as well. First, it checks whether the incoming data is four characters long. if it isn't, it's not decoded. However, there is a problem here in that it doesn't check whether it's a valid hexadecimal number. You can try adding this part yourself.

From then on, it's simple, use substring to break it into two numbers of length 2 each, then convert both to numbers using Integer.parseInt(temp1, 16). The second argument, 16, tells the program that it's a hexadecimal number.

Then you add the two numbers together and get the modulus, which gives you the index of the character you want.

The next function mapChar, does exactly what its name says - gets the number, check if it's in range and get the corresponding letter from the alphabet.

Class Main:

This one is mostly housekeeping: selecting mode (cipher or decipher), telling the program where to get the ciphertext / plaintext, and feeding in a line of the input to the cipher or decipher function.

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

// For user input
char inChar = '\0';
//Whether cipher or decipher mode
int mode = -1;

//For reading input
Scanner sc = new Scanner (System.in);

//Cipher or decipher mode: user input
System.out.println("Select C for enciphering, and D for deciphering");
inChar = sc.next().charAt(0);

if ((inChar=='c')||(inChar=='C')){
System.out.println("Ciphering mode");
mode = 0;
else if ((inChar=='d')||(inChar=='D')){
System.out.println("Deciphering mode");
mode = 1;

//Ciphering data:
if (mode==0){
String ciphered = "";
//For reading from file
File myFile = new File("input1.txt");
Scanner myReader = new Scanner(myFile);
while (myReader.hasNextLine()){
String line = myReader.nextLine();
//Call the cipherLine method from Cipher to get ciphertext
ciphered = ciphered + Cipher.cipherLine(line) + "\n";
} catch (FileNotFoundException e) {
else if (mode ==1){
String deciphered = "";
//For reading from file
File myFile = new File("input2.txt");
Scanner myReader = new Scanner(myFile);
while (myReader.hasNextLine()){
String line = myReader.nextLine();
//Call the decipherLine method from Cipher to get plaintext
deciphered = deciphered + Cipher.decipherLine(line) + "\n";
} catch (FileNotFoundException e) {


The breakdown:

Imports: Java.io.File and Java.io.FileNotFoundException are for reading from file. If you're going to hardcode the ciphertext / plaintext or if it's going to be user input, this is not necessary. Java.util.Scanner is used for both reading user input and reading files.

The first few variables are explained in the code itself.

Next, it asks the user whether to encipher or decipher. If the user input is c for encipher or d for decipher, it runs the respective program (using the mode variable to remember it), otherwise it simply ends. Maybe you can add a message there to let the user know this is happening.

If the mode is 0 (enciphering mode), it reads the input from the selected file line by line, and feeds into encipherLine from the Cipher class, and tacks it onto a string which is then printed once it is done processing the file. You can modify this to output to a file if you want to (which is probably more convenient if you're dealing with a lot of text).

If the mode is 1 (deciphering mode), the process is exactly the same except decipherLine is called.

In conclusion

This cipher is a bit bloated and it's not very efficient, but it's a fun exercise. The biggest advantage here is a result of the bloat, that is, the use of random numbers in the ciphering process makes it nearly immune to most conventional deciphering approaches. 

However, it is not a safe cipher, because once you know the method, you don't really need a key. Another problem is that the length of the message increases by a factor of four which will be problem if you want to cipher a really long message. It could be worse (it could be exponential), but this situation isn't exactly ideal.

Maybe you can also try modifying this to make a new, more secure cipher. Or you could come up with something completely different just for the fun of it. Anyway, I hope you have fun with it.

If you have anything to add, or if you want me to clarify anything, please comment below. I will reply as soon as I can.

You can also follow me on Facebook here.

Until next time!

How to write a character who is smarter than you

We all have that one character (or few) who is significantly smarter than the writer. So, as a writer, how do you write such a character con...