I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
This file is forked from https://gist.github.com/serge-kilimoff/8163233 | |
Supports Python 3 and fixed a few spell errors. | |
""" | |
""" | |
Subclassing Observer for saving states of folders, and load this states at the next observation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find a point that is mutually closest to two or more 3d lines in a least-squares sense. | |
# Based on: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#In_three_dimensions_2 | |
import numpy as np | |
# Create two or more 3d lines in the form of a matrix [[x1,y1,z1], [x2,y2,z2]] | |
lines = [] | |
lines.append(np.asmatrix([[ 4, 0,0], [1,1,4]])) | |
lines.append(np.asmatrix([[-3,-2,0], [4,2,3]])) | |
lines.append(np.asmatrix([[ 0, 0,0], [2,2,6]])) | |
lines.append(np.asmatrix([[ 1, 2,0], [2,0,6]])) |