davecom / classiccomputerscienceproblemsinswift Goto Github PK
View Code? Open in Web Editor NEWSource Code for the Book Classic Computer Science Problems in Swift
License: Apache License 2.0
Source Code for the Book Classic Computer Science Problems in Swift
License: Apache License 2.0
A direct copy of the algorithm found in https://github.com/davecom/ClassicComputerScienceProblemsInSwift/blob/master/Classic%20Computer%20Science%20Problems%20in%20Swift.playground/Pages/Chapter%203.xcplaygroundpage/Contents.swift can give results that violate the same row constraint (if the format is "column: row"). For example:
"[2: 3, 5: 4, 7: 5, 4: 6, 8: 8, 1: 1, 3: 8, 6: 2]"
8:8 and 3:8 are in the same row, which is a violation. Another example:
"[5: 2, 7: 6, 8: 1, 1: 1, 4: 7, 2: 3, 6: 4, 3: 5]"
8:1 and 1:1 are violating the same row constraint
Two queens in the same column is also a constraint, so the following line needs to be added to generate a correct result:
if q1c == q2c { return false } // columns same?
Line 145 and line 155 could be updated to use Float.random(in: 0 ... 1)
When executing Chapter 2 on swift playground with xcode, I get the following error message
Cannot find type 'PriorityQueue' in scope
on line (according to chapter 2.2.5 A* search)
var frontier: PriorityQueue<Node<StateType>> = PriorityQueue<Node<StateType>>(ascending: true, startingValues: [Node(state: initialState, parent: nil, cost: 0, heuristic: heuristicFn(initialState))])
Swift 5.7 and Xcode Version 13.4.1 (13F100)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.