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/python | |
| # encoding: utf-8 | |
| # | |
| # Copyright (c) 2013 deanishe@deanishe.net. | |
| # | |
| # MIT Licence. See http://opensource.org/licenses/MIT | |
| # | |
| # Created on 2013-11-01 | |
| # |
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
| package salesman; | |
| import geography.GeographicPoint; | |
| import java.io.*; | |
| import java.util.ArrayList; | |
| import java.util.HashSet; | |
| import java.util.List; | |
| import java.util.Set; |
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
| # Environment | |
| # export JAVA_HOME=/usr/lib/jvm/java-8-oracle/bin/java | |
| TIJ=/home/maxim/dev/java/thinking_in_java/ # Thinking in Java code | |
| export CLASSPATH=.:..:$TIJ | |
| export PATH=$PATH:/opt/mongodb/bin | |
| export PATH=$PATH:/opt/glassfish4/bin | |
| # export PATH=$PATH:$JAVA_HOME:/opt/mongodb/bin: | |
| # Git |
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
| " Vundle | |
| set nocompatible " be iMproved, required | |
| filetype off " required | |
| " set the runtime path to include Vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " alternatively, pass a path where Vundle should install plugins | |
| "call vundle#begin('~/some/path/here') |
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
| static String InfixToPrefix(String infix) { | |
| char[] array = infix.toCharArray(); | |
| LinkedList<Character> operatorsList = new LinkedList<Character>(); | |
| StringBuffer result = new StringBuffer(); | |
| for (int i = array.length - 1; i >= 0; i--) { | |
| char ch = array[i]; | |
| if (ch > '0' && ch < '9') { | |
| result.insert(0, ch); | |
| } else if (ch != '(' && ch != ')') { | |
| operatorsList.add(ch); |
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
| static String InfixToPostfix(String infix) { | |
| LinkedList<String> stack = new LinkedList<>(); | |
| char[] array = infix.toCharArray(); | |
| StringBuffer result = new StringBuffer(); | |
| List<Character> operators = new ArrayList<>(Arrays.asList('+', '-', '*', '/')); | |
| for (char ch: array) { | |
| if (ch != '(') { | |
| if (ch == ')') { | |
| // check if stack is empty | |
| result.append(stack.pop()); |
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 strong_connected_components(G): | |
| """ | |
| Get strong connected components. | |
| 1. Get indices of vertices. The most connected vertices will | |
| be earlier in list. From these elements we can go further in graph. | |
| 2. Invert graph. | |
| 3. Go through vertices in indices list. Every DFSR cycle gets | |
| one component. | |
| :param G: graph dictionary |