All Projects → maximbilan → Ios Crosswords Generator

maximbilan / Ios Crosswords Generator

Licence: mit
A simple algorithm for generating crosswords written on Swift. Based on Python Crossword Puzzle Generator.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Ios Crosswords Generator

Kickstart Googlecompetition
My Java implementation of Kick Start - Google's Coding Competitions. (not finished)
Stars: ✭ 28 (-30%)
Mutual labels:  algorithm
Sudoku Generator
A Sudoku puzzle generator written in C++ using modified and efficient backtracking algorithm.
Stars: ✭ 33 (-17.5%)
Mutual labels:  algorithm
Lab Notes
😍 有趣的想法 & 有意思灵感 & 小算法实验室,犄角旮旯乱七八糟代码杂货铺,新奇好玩都在这里。
Stars: ✭ 37 (-7.5%)
Mutual labels:  algorithm
Constant Vigilance
Learn this if you want to be a software engineer. Constant vigilance means being continually aware of areas that need improvement. For me, I am constantly searching for valuable resources to ensure I am able to solve any problem that comes my way.
Stars: ✭ 30 (-25%)
Mutual labels:  algorithm
Algorithms
Study cases for Algorithms and Data Structures.
Stars: ✭ 32 (-20%)
Mutual labels:  algorithm
Competitive Programing
个人算法刷题处
Stars: ✭ 33 (-17.5%)
Mutual labels:  algorithm
Algorithm Visualizer
🎆Interactive Online Platform that Visualizes Algorithms from Code
Stars: ✭ 35,995 (+89887.5%)
Mutual labels:  algorithm
Vchsm
C++ 11 algorithm implementation for voice conversion using harmonic plus stochastic models
Stars: ✭ 38 (-5%)
Mutual labels:  algorithm
Algo
📚 My solutions to algorithm problems on various websites
Stars: ✭ 32 (-20%)
Mutual labels:  algorithm
Google Hash Code 2020
More Pizza : Solution for the Practice Round of Google Hash Code 2020
Stars: ✭ 36 (-10%)
Mutual labels:  algorithm
Algorithm
😃基础算法和设计模式(Java & Scala)
Stars: ✭ 30 (-25%)
Mutual labels:  algorithm
Algos
Popular Algorithms and Data Structures implemented in popular languages
Stars: ✭ 966 (+2315%)
Mutual labels:  algorithm
Learn
learn
Stars: ✭ 970 (+2325%)
Mutual labels:  algorithm
Js Tree List
Convert list to tree, managing a tree and its nodes.
Stars: ✭ 30 (-25%)
Mutual labels:  algorithm
Gpwfc
openCL-accelerated python implementation of the Wave Function Collapse procgen algorithm
Stars: ✭ 37 (-7.5%)
Mutual labels:  algorithm
Machine Learning Open Source
Monthly Series - Machine Learning Top 10 Open Source Projects
Stars: ✭ 943 (+2257.5%)
Mutual labels:  algorithm
Rhashmap
Robin Hood hash map library
Stars: ✭ 33 (-17.5%)
Mutual labels:  algorithm
Math Advanced Data Structures And Algorithms
Math, Advanced Data Structures & Algorithms - Please check before use
Stars: ✭ 40 (+0%)
Mutual labels:  algorithm
Awesome Algorithm Question Solution
LeetCode,《剑指offer》中的算法题的题目和解法以及常见算法的实现
Stars: ✭ 988 (+2370%)
Mutual labels:  algorithm
Data Structures Questions
golang sorting algorithm and data construction.
Stars: ✭ 977 (+2342.5%)
Mutual labels:  algorithm

Crosswords Generator

Version License Platform CocoaPods CocoaPods

A simple algorithm for generating crosswords with Swift.
Based on Python Crossword Puzzle Generator.

Installation

CocoaPods:

pod 'CrosswordsGenerator'

Manual:

Copy CrosswordsGenerator.swift, Array2D.swift, ArrayShuffle.swift files to your project.

Using

Initialization and crosswords generation:

let 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"])
generator.generate()

To get result:

let result = crosswordsGenerator.result

The result is an array of structures:

public struct Word {
	public var word = ""
	public var column = 0
	public var row = 0
	public var direction: WordDirection = .Vertical
}

The sample of working:

--- Words ---
["pumpernickel", "syncopation", "albatross", "saffron", "paladin",
"caramel", "snicker", "leaven", "piston", "plague", "coral", "pitch",
"fjord", "coda", "harp", "dawn", "lime", "mist", "yarn", "lip"]

--- Result ---
pumpernickel-
---a-------e-
---l-------a-
caramel-f--v-
o--d----j--e-
r--i----o--n-
a-snicker----
l----o--dawn-
-----d-------
----harp-----
-------------
-------------
-------------

To generate the best crosswords in 10 attempts:

let crosswordsGenerator = CrosswordsGenerator()
crosswordsGenerator.words = ["saffron", "pumpernickel", "leaven", "coda", "paladin", "syncopation", "albatross", "harp", "piston", "caramel", "coral", "dawn", "pitch", "fjord", "lip", "lime", "mist", "plague", "yarn", "snicker"]
crosswordsGenerator.columns = 10
crosswordsGenerator.rows = 10
	
var bestResult: Array = Array()
let attempts = 10
		
for var i: Int = 0; i < attempts; ++i {
	crosswordsGenerator.generate()
	let result = crosswordsGenerator.result
			
	if result.count > bestResult.count {
		bestResult.removeAll()
		for word in result {
			bestResult.append(word)
		}
	}
}

To generate the best crosswords in 60 seconds:

let crosswordsGenerator = CrosswordsGenerator()
crosswordsGenerator.words = ["saffron", "pumpernickel", "leaven", "coda", "paladin", "syncopation", "albatross", "harp", "piston", "caramel", "coral", "dawn", "pitch", "fjord", "lip", "lime", "mist", "plague", "yarn", "snicker"]
crosswordsGenerator.columns = 10
crosswordsGenerator.rows = 10
		
var bestResult: Array = Array()
let startTime = NSDate()
let timeInterval: NSTimeInterval = 10
		
while (fabs(startTime.timeIntervalSinceNow) < timeInterval) {
	crosswordsGenerator.generate()
	let result = crosswordsGenerator.result
			
	if result.count > bestResult.count {
		bestResult.removeAll()
		for word in result {
			bestResult.append(word)
		}
	}
}

Also we have option fillAllWords. After generation of crosswords you can fill words to grid in random places that have not intersections. For example:

let crosswordsGenerator = CrosswordsGenerator(columns: 15, rows: 15, words: ["beijing", "havana", "rome", "paris", "amsterdam"])
crosswordsGenerator.fillAllWords = true
crosswordsGenerator.generate()

amsterdam-b-h--
-----o----e-a--
-----m----i-v--
-----e----j-a--
paris-----i-n--
----------n-a--
----------g----
---------------
---------------

In this repository you can find sample of working of this algorithm. Feel free. Happy coding!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].