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
    
  
  
    
  | def add(matrix1, matrix2): | |
| m1 = len(matrix1) | |
| n1 = len(matrix1[0]) | |
| m2 = len(matrix2) | |
| n2 = len(matrix2[0]) | |
| if m1 != m2 or n1 != n2: | |
| raise ValueError("Given matrices are not the same size.") | |
| result = [[None for _ in range(n1)] for _ in range(m1)] | 
  
    
      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
    
  
  
    
  | def add(matrix1, matrix2): | |
| m1 = len(matrix1) | |
| n1 = len(matrix1[0]) | |
| m2 = len(matrix2) | |
| n2 = len(matrix2[0]) | |
| if m1 != m2 or n1 != n2: | |
| raise ValueError("Given matrices are not the same size.") | |
| result = [[None for _ in range(n1)] for _ in range(m1)] | 
  
    
      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
    
  
  
    
  | /* | |
| * Merge sort in cpp. | |
| * | |
| */ | |
| #include <stdio.h> | |
| #include <vector> | |
| using std::vector; | 
  
    
      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
    
  
  
    
  | """google_Shuffle_Pattern.py | |
| Given a hand of cards, and you need to shuffle it. Assume that you always shuffle | |
| the cards exactly the same way. | |
| Will the cards reach the original state if you keep shuffling it? And if so, given | |
| the shuffle pattern, how many times it will take to shuffle it back to its original | |
| state? | |
| Pattern is given as a integer array A, with no duplicates. | 
  
    
      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
    
  
  
    
  | /** | |
| * codeforces_Inna_and_Dima. | |
| * | |
| * http://codeforces.com/contest/374/problem/C | |
| */ | |
| import java.util.HashMap; | |
| import java.util.Map; | |
  
    
      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
    
  
  
    
  | """codeforces_Inna_And_Pink_Pony.py | |
| http://codeforces.com/contest/374/problem/A | |
| """ | |
| def reachable(args): | |
| (x, y, i, j, a, b) = args | |
| div_x, mod_x = divmod(abs(x - i), a) | |
| if mod_x != 0: | |
| return None | 
  
    
      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
    
  
  
    
  | """hackerrank_Favorite_Sequence.py | |
| https://www.hackerrank.com/contests/w12/challenges/favourite-sequence | |
| """ | |
| from pprint import pprint as p | |
| def toposort(graph): | |
| """""" | |
| # Start of the inner function. | 
  
    
      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
    
  
  
    
  | /** | |
| * Continental_Divide. | |
| * | |
| * Given a geo map, represented as a two-dimension matrix with each | |
| * element as the height value, | |
| * | |
| * Define both left and upper borders adjacent to pacific ocean, and both | |
| * right and down boaders adjacent to atlantic ocean. Also define the | |
| * continental divide as a location, that have flows from itself to both | |
| * pacific ocean and atlantic ocean. At last, define a flow, think it as | 
  
    
      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
    
  
  
    
  | /** | |
| * Minimum_Distance_Sum_To_K_Points_In_Maze. | |
| * | |
| * Given a maze, represented as a matrix (1: wall, 0: path) and k points, find | |
| * the point that the sum of distances from this point to k points is minimum. | |
| * | |
| * If there are more than one point, find all of them. | |
| */ | |
| import java.util.ArrayList; | 
  
    
      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
    
  
  
    
  | """pinabll_maze | |
| Find the exit of the maze for Mr.Pinball. | |
| Assuming: Maze is represented as a matrix, 0: path, 1: wall. | |
| Entrance is at ?? and exit is at ??. | |
| There will be at least one path leads to the exit of the maze. | |
| """ | |
| class Solution(object): | 
NewerOlder