Cyclic, negacyclic and constacyclic codes are part of a larger class of codes called polycyclic codes; namely, those codes which can be viewed as ideals of a factor ring of a polynomial ring. The structure of the ambient ring of polycyclic codes over GR(p(a), m) and generating sets for its ideals are considered. It is shown that these generating sets are strong Groebner bases. A method for finding such sets in the case that a = 2 is given. This explicitly gives the Hamming distance of all cyclic codes of length p(s) over GR(p(2), m). The Hamming distance of certain constacyclic codes of length eta p(s) over F-pm is computed. A method, which determines the Hamming distance of the constacyclic codes of length eta p(s) over GR(p(a), m), where (eta, p) = 1, is described. In particular, the Hamming distance of all cyclic codes of length p(s) over GR(p(2), m) and all negacyclic codes of length 2p(s) over F-pm is determined explicitly. (c) 2012 Elsevier Inc. All rights reserved.