When faced with a problem, try to find a similar problem that is simpler. Solve that. Now you’re left with the question of how to go from there to a solution for the original problem.
The example in the video is to square 498. A quick way to do that it to apply Analogy twice:
Find a similar problem that is simpler: 500 × 496 (two up; two down).
That’s still not obvious, but a simpler problem exists: 1000 × 496 = 496,000
From that solution, you quickly find 500 × 496 = 248,000 (by dividing by two)
We’re left with the question: how to move from that to 4982? Benjamin has that memorized: by adding the square of two: 4982 = 248,004
In case you were wondering, the reason for that is that x2 = (x – n) × (x + n) + n2
So use the Analogy problem-solving strategy to make your problems simpler. It requires some creativity, but it can lead to extremely fast results!
I was quite amazed when I heard that Xamarin offers free online training and certification – that is: when you have an MSDN account.
With Xamarin, you can develop native applications for iOS, Android, Mac and Windows, without having to learn the different programming languages that these native apps are usually developed in: it’s all C#.
Several of my colleagues have used Xamarin, and it appears to be a great option for delivering native apps without having to deal with all the quirks of the different platforms.
Working with end-users on a day-to-day basis is very satisfying. You get to know the people that will benefit from your application. But every now and then they come up with requirements that I don’t immediately know how to implement. A challenge! Let me share such a challenge with you. Read the rest of this entry »
How do you count the number of commas in a string in C#?
When you search the internet for this, you’ll quickly find the two obvious answers:
1. Iterate through the characters of the string, and add 1 when you find a comma:
int total = 0;
for (int i = 0; i < s.Length; i++)
if (s[i] == ',')
2. Use a regular expression:
int total = Regex.Matches(s, ",").Length;
3. My solution, however, would be to treat the string as an array of characters. Arrays are IEnumerable, so we can use LINQ:
int total = s.ToCharArray().Count(c => c == ',');
Today I stumbled on an autobiography of Nikola Tesla, the inventor of AC power and, on a cooler note, the Tesla Coil. He was far ahead of his time, even suggesting world-wide wireless communications in the early 1900’s.
But in reading this quote I found he was far ahead in thinking about work as well. In his time, work was mostly manual labour. The rich did not have to work, so they could afford to be the thinkers. If you wanted to be productive, thinking wasn’t enough. You had work. Read the rest of this entry »
Follow these two steps to create passwords that are secure, but easy to remember.
As more and more of our lives happens online, the thought of someone accessing our online accounts becomes more and more frightening. If someone gets a hold of your password, they can do a lot of damage.
There are three major ways for someone with ill intent to get hold of your password
Ask you for it
Watch you type it in
Snoop it by monitoring the network
The second one, Ask you for it, may surprise you. But how many sites have you visited that ask you to type in a password? And for how many of those do you use the same password?
It’s quite easy for someone with bad intentions to set up a site asking you for an email address and a password, and using the password to access your accounts.
And even when you trust the site, it still may not be safe. Over the years I’ve administered lots of websites, and I’m astonished to see how many databases contain the user’s passwords. Anyone who gets access to such a database can use all of the passwords in it.
Issues 3 and 4 will be addressed in a separate post.
1 and 2, however, can be easily prevented by having a good password. I will show you how to create a password that is difficult to guess, difficult to reuse, but still easy to remember.
I am working on a master/detail page with LINQ to SQL, displaying people’s information. With the person’s name as a key, this is a straightforward thing to do. But it took me a while to figure out how to combine ‘Name’ and ‘Year of birth’ to form the key together. According to my Manifesto, I post my solution here. Take advantage of it. Read the rest of this entry »