Let O be a closed geodesic polygon in S^2. Maps from O into S^2 are said to satisfy tangent boundary conditions if the edges of O are mapped into the geodesics which contain them. Taking O to be an octant of S^2, we compute the infimum Dirichlet energy, Ecal(H), for continuous maps satisfying tangent boundary conditions of arbitrary homotopy type H. The expression for Ecal(H) involves a topological invariant - the spelling length - associated with the (nonabelian) fundamental group of the n-times punctured two-sphere, pi_1(S^2 - {s_1,..., s_n},*). The lower bound for Ecal(H) is obtained from combinatorial group theory arguments, while the upper bound is obtained by constructing explicit representatives which, on all but an arbitrarily small subset of O, are alternatively locally conformal or anticonformal. For conformal and anticonformal classes (classes containing wholly conformal and anticonformal representatives respectively), the expression for Ecal(H) reduces to a previous result involving the degrees of a set of regular values s_1,..., s_n in the target S^2 space. These degrees may be viewed as invariants associated with the abelianization of pi_1(S^2 - {s_1,..., s_n}, *). For nonconformal classes, however, Ecal(H) may be strictly greater than the abelian bound. This stems from the fact that, for nonconformal maps, the number of preimages of certain regular values may necessarily be strictly greater than the absolute value of their degrees. This work is motivated by the theoretical modelling of nematic liquid crystals in confined polyhedral geometries. The results imply new lower and upper bounds for the Dirichlet energy (one-constant Oseen-Frank energy) of reflection-symmetric tangent unit-vector fields in a rectangular prism.