
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
crossword-generator
Advanced tools
A TypeScript library for generating crossword puzzles from a list of words. The library creates clean, properly intersecting crossword grids with intelligent word placement and validation.
npm install crossword-generator
import { generateCrossword } from 'crossword-generator';
const words = ['ARTIST', 'OCTAGON', 'ANGLE', 'DESERT', 'FORCE', 'RENDER', 'PUZZLE'];
const result = generateCrossword(words, {
wordCount: 7,
maxGridSize: 15
});
console.log(result.grid);
// [
// [null, null, null, null, null, 'D'],
// ['P', 'U', 'Z', 'Z', 'L', 'E'],
// [null, null, null, null, null, 'S'],
// [null, 'F', 'O', 'R', 'C', 'E'],
// [null, null, 'C', null, null, 'R'],
// ['A', 'R', 'T', 'I', 'S', 'T'],
// [null, null, 'A', null, null, null],
// ['A', 'N', 'G', 'L', 'E', null],
// [null, null, 'O', null, null, null],
// ['R', 'E', 'N', 'D', 'E', 'R']
// ]
generateCrossword(words, options?)Generates a crossword puzzle from an array of words.
Parameters:
words: string[] - Array of words to use for the crosswordoptions?: CrosswordOptions - Configuration options (optional)Returns: CrosswordResult
| Option | Type | Default | Description |
|---|---|---|---|
wordCount | number | 10 | Target number of words to include. The library tries to achieve this count, but may place fewer words if intersections cannot be found or grid constraints prevent placement. |
maxGridSize | number | 15 | Maximum grid dimensions (both width and height). Only words shorter than this length will be considered. |
maxAttempts | number | 1000 | Maximum number of generation attempts to find the best crossword. |
validationLevel | 'strict' | 'normal' | 'lenient' | 'normal' | Word placement validation strictness. |
minWordLength | number | 3 | Minimum word length to consider. |
maxWordLength | number | maxGridSize | Maximum word length to consider. |
{
grid: (string | null)[][]; // 2D array representing the crossword
placedWords: PlacedWord[]; // Information about placed words
stats: {
wordsUsed: number; // Actual number of words placed
gridSize: { width: number; height: number };
totalIntersections: number;
attempts: number;
};
}
{
word: string; // The word text
startRow: number; // Starting row position
startCol: number; // Starting column position
direction: 'horizontal' | 'vertical';
endRow: number; // Ending row position
endCol: number; // Ending column position
}
The library includes several formatting functions for displaying crosswords:
import { generateCrossword, formatCrosswordForTerminal } from 'crossword-generator';
const result = generateCrossword(words, { wordCount: 10 });
console.log(formatCrosswordForTerminal(result));
Output:
0 1 2 3 4 5
0 · · · · · D
1 P U Z Z L E
2 · · · · · S
3 · F O R C E
4 · · C · · R
5 A R T I S T
6 · · A · · ·
7 A N G L E ·
8 · · O · · ·
9 R E N D E R
Words used:
1. ARTIST → (5, 0)
2. OCTAGON ↓ (3, 2)
3. ANGLE → (7, 0)
4. DESERT ↓ (0, 5)
5. FORCE → (3, 1)
6. RENDER → (9, 0)
7. PUZZLE → (1, 0)
import {
formatCompact,
formatDetailed,
formatClean,
printCrossword
} from 'crossword-generator';
// Print directly to console
printCrossword(result);
// Get formatted strings
const compact = formatCompact(result); // Minified JSON
const detailed = formatDetailed(result); // Full details with stats
const clean = formatClean(result); // Clean array format
import { generateCrossword } from 'crossword-generator';
const words = ['CAT', 'DOG', 'BIRD', 'FISH'];
const crossword = generateCrossword(words, {
wordCount: 4,
maxGridSize: 10
});
console.log(`Generated crossword with ${crossword.stats.wordsUsed} words`);
import { generateCrossword } from 'crossword-generator';
const words = [
'JAVASCRIPT', 'TYPESCRIPT', 'REACT', 'NODE', 'EXPRESS',
'DATABASE', 'API', 'FRONTEND', 'BACKEND', 'FULLSTACK',
// ... 200+ more words
];
const crossword = generateCrossword(words, {
wordCount: 25, // Try to place 25 words
maxGridSize: 20, // Allow larger grid
maxAttempts: 2000, // More attempts for complex puzzles
validationLevel: 'normal'
});
// Note: Actual words placed might be less than 25 if intersections can't be found
console.log(`Placed ${crossword.stats.wordsUsed} out of ${words.length} available words`);
const crossword = generateCrossword(words, {
wordCount: 15, // Target 15 words (may place fewer)
maxGridSize: 12, // Compact 12x12 maximum grid
minWordLength: 4, // Only words with 4+ letters
maxWordLength: 10, // No words longer than 10 letters
validationLevel: 'strict', // Strictest validation
maxAttempts: 500 // Fewer attempts for faster generation
});
The crossword generation algorithm:
wordCount option represents a target that the library tries to achieve. The actual number of words placed may be lower if:
string represents letters and null represents empty cellsmaxGridSize are automatically filtered outThe library is written in TypeScript and includes full type definitions. All types are exported for use in your projects:
import {
CrosswordOptions,
CrosswordResult,
PlacedWord,
CrosswordGrid,
Direction
} from 'crossword-generator';
MIT
Issues and pull requests are welcome! Please ensure all tests pass and follow the existing code style.
FAQs
A TypeScript library for generating crossword puzzles
The npm package crossword-generator receives a total of 15 weekly downloads. As such, crossword-generator popularity was classified as not popular.
We found that crossword-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.