func (b Board) keyedUsedWords(tiles map[int]map[int]tile.Tile, ord func(tp tile.Position) int) (map[int][]string, int) {
	keyedUsedWords := make(map[int][]string, len(tiles))
	wordCount := 0
	for z, zTiles := range tiles {
		tilePositions := make([]tile.Position, 0, len(zTiles))
		for _, t := range zTiles {
			tilePositions = append(tilePositions, b.UsedTiles[t.ID])
		}
		sort.Slice(tilePositions, func(i, j int) bool {
			return ord(tilePositions[i]) < ord(tilePositions[j])
		})
		var buf bytes.Buffer
		var zWords []string
		for i, tp := range tilePositions {
			if i > 0 && ord(tilePositions[i-1]) < ord(tp)-1 {
				if buf.Len() > 1 {
					zWords = append(zWords, buf.String())
				}
				buf.Reset()
			}
			buf.WriteRune(rune(tp.Tile.Ch))
		}
		if buf.Len() > 1 {
			zWords = append(zWords, buf.String())
		}
		keyedUsedWords[z] = zWords
		wordCount += len(zWords)
	}
	return keyedUsedWords, wordCount
}
// keyedUsedWords aggregates the words in the direction specified by ord into a map of words foreach row in the tiles
// the total number of words is also returned
keyedUsedWords aggregates the words in the direction specified by ord into a map of words foreach row in the tiles
the total number of words is also returned
// keyedUsedWords aggregates the words in the direction specified by ord into a map of words foreach row in the tiles // the total number of words is also returned
func (b Board) keyedUsedWords(tiles map[int]map[int]tile.Tile, ord func(tp tile.Position) int) (map[int][]string, int) {
	keyedUsedWords := make(map[int][]string, len(tiles))
	wordCount := 0
	for z, zTiles := range tiles {
		tilePositions := make([]tile.Position, 0, len(zTiles))
		for _, t := range zTiles {
			tilePositions = append(tilePositions, b.UsedTiles[t.ID])
		}
		sort.Slice(tilePositions, func(i, j int) bool {
			return ord(tilePositions[i]) < ord(tilePositions[j])
		})
		var buf bytes.Buffer
		var zWords []string
		for i, tp := range tilePositions {
			if i > 0 && ord(tilePositions[i-1]) < ord(tp)-1 {
				if buf.Len() > 1 {
					zWords = append(zWords, buf.String())
				}
				buf.Reset()
			}
			buf.WriteRune(rune(tp.Tile.Ch))
		}
		if buf.Len() > 1 {
			zWords = append(zWords, buf.String())
		}
		keyedUsedWords[z] = zWords
		wordCount += len(zWords)
	}
	return keyedUsedWords, wordCount
}
func ( b Board ) keyedUsedWords ( tiles map [ int ] map [ int ] tile . Tile , ord func ( tp tile . Position ) int ) ( map [ int ] [ ] string , int ) { keyedUsedWords := make ( map [ int ] [ ] string , len ( tiles ) ) wordCount := 0 for z , zTiles := range tiles { tilePositions := make ( [ ] tile . Position , 0 , len ( zTiles ) ) for _ , t := range zTiles { tilePositions = append ( tilePositions , b . UsedTiles [ t . ID ] ) } sort . Slice ( tilePositions , func ( i , j int ) bool { return ord ( tilePositions [ i ] ) < ord ( tilePositions [ j ] ) } ) var buf bytes . Buffer var zWords [ ] string for i , tp := range tilePositions { if i > 0 && ord ( tilePositions [ i - 1 ] ) < ord ( tp ) - 1 { if buf . Len ( ) > 1 { zWords = append ( zWords , buf . String ( ) ) } buf . Reset ( ) } buf . WriteRune ( rune ( tp . Tile . Ch ) ) } if buf . Len ( ) > 1 { zWords = append ( zWords , buf . String ( ) ) } keyedUsedWords [ z ] = zWords wordCount += len ( zWords ) } return keyedUsedWords , wordCount }
keyedUsedWords aggregates the words in the direction specified by ord into a map of words foreach row in the tiles
the total number of words is also returned
keyedUsedWords aggregates the words in the direction specified by ord into a map of words foreach row in the tiles the total number of words is also returned