Programming exercise: permutations of a string

[Permalink]

The problem is to implement a function that outputs all possible permutations of the characters in a string. Unlike combinations, two permutations are considered distinct if they contain the same characters, but in a different order. Also, for the purposes of this exercise, each occurrence of a repeated character is considered to be a distinct character. That is, if the input is “aaa”, the output should be six repetitions of “aaa”. The permutations may be output in any order.

This exercise, like the previous one on combinations of a string, is from the book Programming Interviews Exposed by John Mongan and Noah Suojanen[1]\(\)… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit
0 Comments

Programming exercise: combinations of a string

[Permalink]

The problem is to implement a function that outputs all possible combinations of the characters in a string (with length ranging from one to the length of the string). Unlike permutations, two combinations are considered to be the same if they contain the same characters, but in a different order. Another way to define the problem is to find the power set of the characters of the string (excluding the empty set).

Like the previous exercise, this one is also from the book Programming Interviews Exposed by John Mongan and Noah Suojanen[1]\(\)… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit
0 Comments

Programming exercise: maximum value in integer array, part 1

[Permalink]

This exercise is just a little bit more substantial than the last one — but not by very much. Given an array of \(n\) non-negative integers, find the maximum value in the array, or return \(-1\) if the array is empty. Obviously, the use of any built-in maximum-finding function is forbidden. While the problem is almost trivial, it does illustrate how each language works with array or vector data types, as well as how it handles iteration.

This exercise, like some of the other ones that I will also be going through, is from the book Programming Interviews Exposed by John Mongan and Noah Suojanen[1]… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit
0 Comments

Programming exercise: Hello, world!

[Permalink]

As a preliminary exercise to jog my memory, here is the obligatory “Hello, world!” program in a variety of languages. On the one hand, the programs do nothing except output a string, and so don’t illustrate very much about the respective languages. On the other hand, the simplicity of the task does illustrate the difference between languages that allow you to begin coding right away versus those that require a considerable amount of setting up (importing libraries, declaring classes, etc.) before you even have a functioning program… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit
0 Comments

Programming exercises and comparison of programming languages

[Permalink]

I started programming when I was eight years old. The first programming language I learned was Basic, followed very shortly by C and 8086 assembly language. During elementary school, I was also exposed to Pascal and Logo. I ignored Pascal because it seemed to me that anything I could do in it I could already do with C, and although I had some fun with Logo’s turtle graphics, I didn’t take it very seriously. At the time, I didn’t appreciate its connection with Lisp and other “serious” programming languages… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit
0 Comments

My nerd scores

[Permalink]

Someone asked me to take the “nerd tests”, and these were my results… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit

No related posts.

0 Comments

Fixing the site’s appearance in Internet Explorer

[Permalink]

I just spent the day in the library, where I used Internet Explorer on a public terminal. I knew that IE did not render CSS properly, but until I tried to use this web site for several hours in IE, I had no idea how bad things were. I’ve hacked the CSS so that it displays reasonably well in IE now. I hope this didn’t mess things up for other browsers. Grr… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit

No related posts.

0 Comments

Two popular books on fuzzy logic

[Permalink]

These are two popular books on fuzzy logic: Bart Kosko’s Fuzzy Thinking: The New Science of Fuzzy Logic, and Daniel McNeill and Paul Freiberger’s Fuzzy Logic.

Fuzzy logic was pioneered by Dr. Lotfi Zadeh, whom I met when he gave a lecture at the University of Toronto… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit

If you like this post, you might also like:

  1. Two popular books on the human genome
0 Comments

365 Ways to Kiss Your Love by Tomima Edmark

[Permalink]

This was a gift from my ex-girlfriend while we were still dating. The lip print on the transparent card is actually hers, and the silk handkerchief is what the book was wrapped in when she gave it to me.

It was a very thoughtful and romantic gift… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit

No related posts.

0 Comments

Funk & Wagnalls Canadian College Dictionary

[Permalink]

I had actually obtained this book shortly after arriving in Canada at the age of eight. I think it was either a gift or a hand-me-down, but I don’t remember exactly how I got it… » [Expand post] [Permalink]

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit

No related posts.

0 Comments