How to resolve the algorithm Isograms and heterograms step by step in the J programming language
How to resolve the algorithm Isograms and heterograms step by step in the J 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:
-
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.
-
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:
Step by Step solution about How to resolve the algorithm Isograms and heterograms step by step in the J programming language
Source code in the j programming language
isogram=: {{ {. (#~ 1= #@~.) #/.~ y }} S:0
(-: /:~) cutLF tolower fread 'unixdict.txt'
1
> (/: -@isogram,.-@#@>) (#~ 1<isogram) cutLF tolower fread 'unixdict.txt'
aaa
iii
beriberi
bilabial
caucasus
couscous
teammate
appall
emmett
hannah
murmur
tartar
testes
anna
coco
dada
deed
dodo
gogo
isis
juju
lulu
mimi
noon
otto
papa
peep
poop
teet
tete
toot
tutu
ii
> (/: -@#@>) (#~ (10 < #@>) * 1=isogram) cutLF tolower fread 'unixdict.txt'
ambidextrous
bluestocking
exclusionary
incomputable
lexicography
loudspeaking
malnourished
atmospheric
blameworthy
centrifugal
christendom
consumptive
countervail
countryside
countrywide
disturbance
documentary
earthmoving
exculpatory
geophysical
inscrutable
misanthrope
problematic
selfadjoint
stenography
sulfonamide
switchblade
switchboard
switzerland
thunderclap
valedictory
voluntarism
You may also check:How to resolve the algorithm Walk a directory/Recursively step by step in the IDL programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the R programming language
You may also check:How to resolve the algorithm Substring step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Accumulator factory step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Sort stability step by step in the Common Lisp programming language