How to resolve the algorithm Isograms and heterograms step by step in the Phix programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Isograms and heterograms step by step in the Phix programming language

Table of Contents

Problem Statement

For the purposes of this task, an isogram means a string where each character present is used the same number of times and an n-isogram means an isogram where each character present is used exactly n times. A heterogram means a string in which no character occurs more than once. It follows that a heterogram is the same thing as a 1-isogram.

caucasus is a 2-isogram because the letters c, a, u and s all occur twice. atmospheric is a heterogram because all its letters are used once only.

Using unixdict.txt and ignoring capitalization:

  1. Find and display here all words which are n-isograms where n > 1. Present the results as a single list but sorted as follows: a. By decreasing order of n; b. Then by decreasing order of word length; c. Then by ascending lexicographic order.

  2. Secondly, find and display here all words which are heterograms and have more than 10 characters. Again present the results as a single list but sorted as per b. and c. above.

Let's start with the solution: