[R] Help to write the R-code, please

Александр Дубровский dubrovv@@kkyy @end|ng |rom gm@||@com
Thu Dec 5 12:39:07 CET 2019


Task:
A family of sets of letters is given. Find K for which one can construct a
set consisting of K letters, each of them belonging to exactly K sets of a
given family.

Possible solution:
For each letter, we will have a separate 'scoop', in which we will' put '
the letter. This can be done using array A of 255 elements. In this case,
the number of the 'scoop' corresponding to a letter is determined by the
letter code (it is known that any letter is encoded by some binary number
containing 8 digits - called bits; in Pascal, its code can be determined by
using the ord function). When viewing the sets, let's count how many times
each letter met. This is done as follows. When you meet a letter, increase
the contents of the corresponding array element by 1. The initial contents
of the array elements are 0. After viewing the letters of all sets,
elements a determine the number of corresponding letters, and therefore the
number of sets that have the corresponding letter (because in one set, all
elements are different!). Using similarly array B from 255 elements (more
need not, so as the desired the number of to on condition not exceeds
number of letters) count the number of units, twos and so on in array A.
Maximum significance index K, for which K=B[K] and will solution meet the
tasks.

	[[alternative HTML version deleted]]



More information about the R-help mailing list