In the last time some papers were devoted to the study of the con- nections between binary block codes and BCK-algebras. In this paper, we try to generalize these results to n-ary block codes, providing an algorithm which allows us to construct a BCK-algebra from a given n-ary block code.