Anagrams of a Word

anagram_sampleLast week I was talking with a software engineer. While chatting the description of a problem / challenge came up. The description, as far as I can recall, follows:

“Given a text file with all (most would be more precise) English language words in lower-case, find all anagrams for a specified word”.

An example of an anagram was discussed. At the time I was thinking on palindromes and was not able to concentrate on the definition of anagrams. I thought that an anagram consists of a set of letters in any order and letters may repeat. For example, “ana” and “anna” would fit my incorrect definition. I mentioned that I would spend some time on my own and come up with a solution. Continue reading “Anagrams of a Word”

Top 10 Words in a Text File

how-to-find-highest-repeating-word-from-a-file-in-javaThis entry describes the implementation of an algorithm used to display the top ten (the number is just a constant in the solution) words found in a text file. The solution is implemented in Java.

As is typical, a challenge is described by some requirements. The requirements for this challenge follows:

“Given a text file holding some text (a few thousand words) generate the list of the top ten words found in the text file”. Continue reading “Top 10 Words in a Text File”

Split Words

splitstringI have had a stressful week. Glad the weekend arrived. Today I will provide my solution, including the thinking process, to a common and quite popular programming challenge. I have encountered several variations of it. The base problem follows:

“Split a text string into words. Words only contain ASCII letters which for simplicity may be treated as lower (a – z) or upper case (A – Z) characters (developer’s choice)”.

Continue reading “Split Words”

Fraction Recurring Decimal

recurring_decimalsFor the past few months I had been working attempting to solve a challenge per day on HackerRank. I like that site. A couple weeks ago I was introduced to LeetCode. Challenges seem to be more intense and requirements seem to be vaguer. Knowing this, one needs to think and plan the approach / algorithm with greater care and expect to fail unit tests that one would not think off. I just finished a challenge and decided to post in this blog my approach to solving it. Continue reading “Fraction Recurring Decimal”

Bag Algorithm

bag_queue_stackHave to admit it, after a few (will not say how many) years studying Computer Science, architecting and developing systems in multiple programming languages and platforms I had missed the Bag algorithm :o( Gladly I am spending time reading and performing several (do not have time to work on all) exercises and examples in the Algorithms fourth edition book by Robert Sedgewick and Kevin Wayne.

The Bag algorithm is used to implement an object that stores in no particular order items added to it. There is an Application Programming Interface (API) to get the size of the bag and to determine if it is empty. If an Iterator is implemented, then a client is able to iterate in no particular order through the items in a bag. Continue reading “Bag Algorithm”

Generics Implementation

algorithms_fourth_edition_back_coverThis blog entry is based on the example on page 141 of Algorithms fourth edition by Robert Sedgewick and Kevin Wayne. I am reading the book as a refresher and learning experience on computer algorithms. Initially what called my attention was the statement that it contains 50 algorithms that every programmer should know. I want to make sure I have a good handle on those algorithms. After reading the first few chapters which have not cover the algorithms yet, I feel that the way the ground work is presented is very educational, direct to the point and simple to follow. I always like simplicity in code and documentation. Elegant code is very hard to find and write. This book seems that it should help readers achieve such goal. Continue reading “Generics Implementation”


stackThis blog entry was motivated by the description and implementation of Java Generics in the Algorithms fourth edition book by Robert Sedgewick and Kevin Wayne. The code in this post is based on their implementation. I did some minor changes.

Collections, Generics and Iterators are important concepts in object oriented programming languages. It is central to understand the reasons for them and the associated ideas. If you are interested (and you should if you work with object oriented languages) get a copy of the book and take a look at pages 132 – 141. Continue reading “Generics”

Evaluate Example – Algorithms Fourth Edition

two-stack-algorithmI am reading, experimenting with the examples and working on some (do not have enough time to address them all) exercises using the Algorithms fourth edition book by Robert Sedgewick and Kevin Wayne. I am having a good time refreshing and learning some new things.

This morning I was reading Dijkstra’s Two-Stack Algorithm for Expression Evaluation on page 129. The algorithm is well explained and works. What called my attention is that the actual code does not seem to work on my machine. I already sent a message to professor Sedgewick for clarification. Continue reading “Evaluate Example – Algorithms Fourth Edition”

Algorithms – Chapter 1 and 2

algorithms_fourth_editionI typically write one blog entry per book I read. In this blog, Algorithms Fourth Edition by Robert Sedgewick and Kevin Wayne will be split in comments per one or more chapters.

A few weeks ago I decided to read Algorithms and go over most of the exercises. I wish I would have enough time to tackle them all. This morning I finished reading the first two chapters. So far, so good. Continue reading “Algorithms – Chapter 1 and 2”

Symbolic Links on .NET

word_to_pdfI was talking with a colleague earlier today. A few days ago the requirements for a short project specified a service / application that would monitor an input folder (e.g., c:\temp\DocFolder) for *.doc (Word) files and generate in an output folder (e.g., c:\temp\PDFFolder) a *.pdf (Portable Document Format) version of the files. The application / server was implemented and tested. Continue reading “Symbolic Links on .NET”