2016年10月18日 星期二
2016年10月17日 星期一
How to Modify the Shell Path in macOS
1. cd cd~
2. vi .bash_profile
3. export PATH="/Users/charles.lo/Library/Android/sdk/platform-tools:$PATH"
MAC finder show hide hidden file
顯示隱藏檔案:defaults write com.apple.finder AppleShowAllFiles TRUE;\killall Finder
不顯示隱藏檔案:defaults write com.apple.finder AppleShowAllFiles FALSE;\killall Finder
不顯示隱藏檔案:defaults write com.apple.finder AppleShowAllFiles FALSE;\killall Finder
Install Geany on Mac OSX
About the App
- App name: Geany
- App description: geany (App: Geany.app)
- App website: http://www.geany.org
Install the App
- Press
Command+Space
and type Terminal and press enter/return key. - Run in Terminal app:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null
and press enter/return key. Wait for the command to finish. - Run:
brew cask install geany
2016年10月14日 星期五
Git tab autocomplete on OSX 10.11 El Capitan
Step 1: Download auto completion script:
>> cd ~
>> curl -O https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
Step 2: Update .bash_profile
2016年10月13日 星期四
How to Enable Tab Completion in Mac OS X Terminal
- Use pico, nano, vi or whatever your favorite text editor is to edit/create .inputrc, I’ll use pico for this walkthrough.
pico .inputrc
- Paste in the following three lines of rules:
set completion-ignore-case on
set show-all-if-ambiguous on
TAB: menu-complete
- Press Control+O to save changes to .inputrc followed by Control+X to quit
- Close and reopen Terminal for the rules to take effect
- Start typing a path or command and press the Tab key to see this feature in action
2016年10月2日 星期日
Beautiful Binary String
Alice has a binary string, , of length . She thinks a binary string is beautiful if and only if it doesn't contain thesubstring .
In one step, Alice can change a to a (or vice-versa). Count and print the minimum number of steps needed to make Alice see the string as beautiful.
Input Format
The first line contains an integer, (the length of binary string ).
The second line contains a single binary string, , of length .
The second line contains a single binary string, , of length .
Constraints
- Each character in .
Output Format
Print the minimum number of steps needed to make the string beautiful.
Sample Input 0
7
0101010
Sample Output 0
2
Sample Input 1
5
01100
Sample Output 1
0
Sample Input 2
10
0100101010
Sample Output 2
3
Explanation
Sample Case 0:
In this sample,
The figure below shows a way to get rid of each instance of :
Because we were able to make the string beautiful by changing characters ( and ), we print .
Sample Case 1:
In this sample
The substring does not occur in , so the string is already beautiful and we print .
====================================================
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String B = in.next();
int i = 0, out = 0, next = 0;
if (B.indexOf("010") >= 0) {
while (i < B.length()) {
next = B.indexOf("010", i) + 3;
if (next < i) {
break;
}
i = next;
out++;
}
} else {}
System.out.println(out);
}
}
Beautiful Binary String
Alice has a binary string, , of length . She thinks a binary string is beautiful if and only if it doesn't contain thesubstring .
In one step, Alice can change a to a (or vice-versa). Count and print the minimum number of steps needed to make Alice see the string as beautiful.
Input Format
The first line contains an integer, (the length of binary string ).
The second line contains a single binary string, , of length .
The second line contains a single binary string, , of length .
Constraints
- Each character in .
Output Format
Print the minimum number of steps needed to make the string beautiful.
Sample Input 0
7
0101010
Sample Output 0
2
Sample Input 1
5
01100
Sample Output 1
0
Sample Input 2
10
0100101010
Sample Output 2
3
Explanation
Sample Case 0:
In this sample,
The figure below shows a way to get rid of each instance of :
Because we were able to make the string beautiful by changing characters ( and ), we print .
Sample Case 1:
In this sample
The substring does not occur in , so the string is already beautiful and we print .
====================================================
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String B = in.next();
int i = 0, out = 0, next = 0;
if (B.indexOf("010") >= 0) {
while (i < B.length()) {
next = B.indexOf("010", i) + 3;
if (next < i) {
break;
}
i = next;
out++;
}
} else {
}
System.out.println(out);
}
}
訂閱:
文章 (Atom)