{"id":13961705,"url":"https://github.com/maximbilan/iOS-Crosswords-Generator","last_synced_at":"2025-07-21T06:31:35.001Z","repository":{"id":56906823,"uuid":"42308951","full_name":"maximbilan/iOS-Crosswords-Generator","owner":"maximbilan","description":"A simple algorithm for generating crosswords written on Swift. Based on Python Crossword Puzzle Generator.","archived":false,"fork":false,"pushed_at":"2018-09-22T08:49:19.000Z","size":65,"stargazers_count":62,"open_issues_count":0,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-05T07:17:26.297Z","etag":null,"topics":["algorithm","best-crosswords","crossword-generator","generating-crosswords","ios","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximbilan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-11T13:04:38.000Z","updated_at":"2025-05-07T21:19:05.000Z","dependencies_parsed_at":"2022-08-21T02:21:00.448Z","dependency_job_id":null,"html_url":"https://github.com/maximbilan/iOS-Crosswords-Generator","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/maximbilan/iOS-Crosswords-Generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FiOS-Crosswords-Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FiOS-Crosswords-Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FiOS-Crosswords-Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FiOS-Crosswords-Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximbilan","download_url":"https://codeload.github.com/maximbilan/iOS-Crosswords-Generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FiOS-Crosswords-Generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266253548,"owners_count":23900052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","best-crosswords","crossword-generator","generating-crosswords","ios","swift"],"created_at":"2024-08-08T17:01:22.209Z","updated_at":"2025-07-21T06:31:34.695Z","avatar_url":"https://github.com/maximbilan.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Crosswords Generator\n\n[![Version](https://img.shields.io/cocoapods/v/CrosswordsGenerator.svg?style=flat)](http://cocoadocs.org/docsets/CrosswordsGenerator)\n[![License](https://img.shields.io/cocoapods/l/CrosswordsGenerator.svg?style=flat)](http://cocoadocs.org/docsets/CrosswordsGenerator)\n[![Platform](https://img.shields.io/cocoapods/p/CrosswordsGenerator.svg?style=flat)](http://cocoadocs.org/docsets/CrosswordsGenerator)\n[![CocoaPods](https://img.shields.io/cocoapods/dt/CrosswordsGenerator.svg)](https://cocoapods.org/pods/CrosswordsGenerator)\n[![CocoaPods](https://img.shields.io/cocoapods/dm/CrosswordsGenerator.svg)](https://cocoapods.org/pods/CrosswordsGenerator)\n\nA simple algorithm for generating crosswords with \u003ci\u003eSwift\u003c/i\u003e.\u003cbr\u003e\nBased on \u003ca href=\"http://bryanhelmig.com/python-crossword-puzzle-generator/\"\u003e Python Crossword Puzzle Generator.\u003c/a\u003e\n\n# Installation\n\n\u003cb\u003eCocoaPods:\u003c/b\u003e\n\n\u003cpre\u003e\npod 'CrosswordsGenerator'\n\u003c/pre\u003e\n\n\u003cb\u003eManual:\u003c/b\u003e\n\n\u003cpre\u003e\nCopy \u003ci\u003eCrosswordsGenerator.swift\u003c/i\u003e, \u003ci\u003eArray2D.swift\u003c/i\u003e, \u003ci\u003eArrayShuffle.swift\u003c/i\u003e files to your project.\n\u003c/pre\u003e\n\n# Using\n\nInitialization and crosswords generation:\n\n\u003cpre\u003e\nlet generator = CrosswordsGenerator(columns: 10, rows: 10, maxLoops: 2000, words: [\"saffron\", \"pumpernickel\", \"leaven\", \"coda\", \"paladin\", \"syncopation\", \"albatross\", \"harp\", \"piston\", \"caramel\", \"coral\", \"dawn\", \"pitch\", \"fjord\", \"lip\", \"lime\", \"mist\", \"plague\", \"yarn\", \"snicker\"])\ngenerator.generate()\n\u003c/pre\u003e\n\nTo get result:\n\n\u003cpre\u003e\nlet result = crosswordsGenerator.result\n\u003c/pre\u003e\n\nThe result is an array of structures:\n\u003cpre\u003e\npublic struct Word {\n\tpublic var word = \"\"\n\tpublic var column = 0\n\tpublic var row = 0\n\tpublic var direction: WordDirection = .Vertical\n}\n\u003c/pre\u003e\n\nThe sample of working:\n\n\u003cpre\u003e\n--- Words ---\n[\"pumpernickel\", \"syncopation\", \"albatross\", \"saffron\", \"paladin\",\n\"caramel\", \"snicker\", \"leaven\", \"piston\", \"plague\", \"coral\", \"pitch\",\n\"fjord\", \"coda\", \"harp\", \"dawn\", \"lime\", \"mist\", \"yarn\", \"lip\"]\n\n--- Result ---\npumpernickel-\n---a-------e-\n---l-------a-\ncaramel-f--v-\no--d----j--e-\nr--i----o--n-\na-snicker----\nl----o--dawn-\n-----d-------\n----harp-----\n-------------\n-------------\n-------------\n\u003c/pre\u003e\n\nTo generate the best crosswords in 10 attempts:\n\n\u003cpre\u003e\nlet crosswordsGenerator = CrosswordsGenerator()\ncrosswordsGenerator.words = [\"saffron\", \"pumpernickel\", \"leaven\", \"coda\", \"paladin\", \"syncopation\", \"albatross\", \"harp\", \"piston\", \"caramel\", \"coral\", \"dawn\", \"pitch\", \"fjord\", \"lip\", \"lime\", \"mist\", \"plague\", \"yarn\", \"snicker\"]\ncrosswordsGenerator.columns = 10\ncrosswordsGenerator.rows = 10\n\t\nvar bestResult: Array\u003cCrosswordsGenerator.Word\u003e = Array()\nlet attempts = 10\n\t\t\nfor var i: Int = 0; i \u003c attempts; ++i {\n\tcrosswordsGenerator.generate()\n\tlet result = crosswordsGenerator.result\n\t\t\t\n\tif result.count \u003e bestResult.count {\n\t\tbestResult.removeAll()\n\t\tfor word in result {\n\t\t\tbestResult.append(word)\n\t\t}\n\t}\n}\n\u003c/pre\u003e\n\nTo generate the best crosswords in 60 seconds:\n\n\u003cpre\u003e\nlet crosswordsGenerator = CrosswordsGenerator()\ncrosswordsGenerator.words = [\"saffron\", \"pumpernickel\", \"leaven\", \"coda\", \"paladin\", \"syncopation\", \"albatross\", \"harp\", \"piston\", \"caramel\", \"coral\", \"dawn\", \"pitch\", \"fjord\", \"lip\", \"lime\", \"mist\", \"plague\", \"yarn\", \"snicker\"]\ncrosswordsGenerator.columns = 10\ncrosswordsGenerator.rows = 10\n\t\t\nvar bestResult: Array\u003cCrosswordsGenerator.Word\u003e = Array()\nlet startTime = NSDate()\nlet timeInterval: NSTimeInterval = 10\n\t\t\nwhile (fabs(startTime.timeIntervalSinceNow) \u003c timeInterval) {\n\tcrosswordsGenerator.generate()\n\tlet result = crosswordsGenerator.result\n\t\t\t\n\tif result.count \u003e bestResult.count {\n\t\tbestResult.removeAll()\n\t\tfor word in result {\n\t\t\tbestResult.append(word)\n\t\t}\n\t}\n}\n\u003c/pre\u003e\n\nAlso we have option \u003ci\u003efillAllWords\u003c/i\u003e. After generation of crosswords you can fill words to grid in random places that have not intersections. For example:\n\n\u003cpre\u003e\nlet crosswordsGenerator = CrosswordsGenerator(columns: 15, rows: 15, words: [\"beijing\", \"havana\", \"rome\", \"paris\", \"amsterdam\"])\ncrosswordsGenerator.fillAllWords = true\ncrosswordsGenerator.generate()\n\namsterdam-b-h--\n-----o----e-a--\n-----m----i-v--\n-----e----j-a--\nparis-----i-n--\n----------n-a--\n----------g----\n---------------\n---------------\n\u003c/pre\u003e\n\nIn this repository you can find sample of working of this algorithm. Feel free. Happy coding! \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2FiOS-Crosswords-Generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximbilan%2FiOS-Crosswords-Generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2FiOS-Crosswords-Generator/lists"}