There’s a chess board of size
Knight can step by going forward or backward two units in one direction, and one units in the other direction.
Find a way to position
| import Cocoa | |
| let session = NSURLSession.sharedSession() | |
| let request = NSURLRequest(URL: NSURL(string: "http://example.com")!) | |
| let dataToUpload = "Some Arbitrary Data".dataUsingEncoding(NSUTF8StringEncoding) | |
| let uploadTask = session.uploadTaskWithRequest(request, fromData: dataToUpload, | |
| completionHandler: { (responseData, response, error) in | |
| // Check on some response headers (if it's HTTP) |
| class Node: | |
| def __init__(self, label=None, data=None): | |
| self.label = label | |
| self.data = data | |
| self.children = dict() | |
| def addChild(self, key, data=None): | |
| if not isinstance(key, Node): | |
| self.children[key] = Node(key, data) | |
| else: |
| using UnityEngine; | |
| using System.Collections; | |
| /// <summary> | |
| /// Defines angle limits as the maximum deviation away from the rotation of this object. | |
| /// (in other words: if the yawlimit is 45, then you can only move up to 45 degrees away from this rotation in both directions. | |
| /// This means the total angle available would be an angle of 90 degrees) | |
| /// An angle of 180 allows complete freedom of movement on that axis. | |
| /// </summary> | |
| public class FocusPoint : MonoBehaviour |
| // | |
| // RW.swift | |
| // Web | |
| // | |
| // Created by Mike Chirico on 10/15/15. | |
| // Copyright © 2015 Mike Chirico. All rights reserved. | |
| // | |
| import UIKit |
| func openAndSelectFile(filename:String){ | |
| let files = [NSURL(fileURLWithPath: filename)]; | |
| NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs(files); | |
| } |
| let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | |
| extension Array { | |
| func splitBy(subSize: Int) -> [[Element]] { | |
| return 0.stride(to: self.count, by: subSize).map { startIndex in | |
| let endIndex = startIndex.advancedBy(subSize, limit: self.count) | |
| return Array(self[startIndex ..< endIndex]) | |
| } | |
| } | |
| } |
| import UIKit | |
| extension UIImage { | |
| subscript (x: Int, y: Int) -> UIColor? { | |
| guard x >= 0 && x < Int(size.width) && y >= 0 && y < Int(size.height), | |
| let cgImage = cgImage, | |
| let provider = cgImage.dataProvider, | |
| let providerData = provider.data, | |
| let data = CFDataGetBytePtr(providerData) else { | |
| return nil |
| // | |
| // NSImage+pixelData.swift | |
| // | |
| // Created by Figgleforth on 5/21/15. | |
| // Copyright (c) 2015 Bojan Percevic. All rights reserved. | |
| // | |
| import AppKit | |
| extension NSImage { |
| func resize(image: NSImage, w: Int, h: Int) -> NSImage { | |
| var destSize = NSMakeSize(CGFloat(w), CGFloat(h)) | |
| var newImage = NSImage(size: destSize) | |
| newImage.lockFocus() | |
| image.drawInRect(NSMakeRect(0, 0, destSize.width, destSize.height), fromRect: NSMakeRect(0, 0, image.size.width, image.size.height), operation: NSCompositingOperation.CompositeSourceOver, fraction: CGFloat(1)) | |
| newImage.unlockFocus() | |
| newImage.size = destSize | |
| return NSImage(data: newImage.TIFFRepresentation!)! | |
| } |