This file contains 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
#palindrome | |
#tested under Python3 | |
def process_text(text): | |
text = text.lower() | |
forbidden = (' ', '.', '?', '!', ':', ';', '-', '—', '(', ')', '[', ']', '’', '“', '”', '/', ',', '"') | |
for i in forbidden: | |
text = text.replace(i, '') | |
return text | |
def reverse(text): |
This file contains 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
#scan a directory iteratively and get specific type files | |
#tested under Python3 | |
import os | |
import os.path | |
def print_filename(item, sou_dir, type): | |
(filepath, filename) = os.path.split(item) | |
if type == os.path.splitext(filename)[1]: | |
sourcefile = os.path.join(sou_dir, item) | |
print(sourcefile) |
This file contains 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
#detect files' encoding | |
#tested under Python3 | |
from chardet.universaldetector import UniversalDetector | |
import os | |
import os.path | |
def detect(filename, filetype, out_enc='utf-8'): | |
(filepath, name) = os.path.split(filename) | |
if filetype == os.path.splitext(name)[1]: | |
try: |
This file contains 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
#scan a directory iteratively, copy particular file to a new directory | |
#tested under Python3 | |
import os | |
import os.path | |
import shutil | |
def copy_file(item, sou_dir, des_dir, type): | |
(filepath, filename) = os.path.split(item) | |
if type == os.path.splitext(filename)[1]: | |
sourcefile = os.path.join(sou_dir, item) |
This file contains 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
#scan a directory iteratively, copy particular file to a new directory | |
#each file in new directory has is own new directory that name is same as the file | |
#tested under Python3 | |
import os | |
import os.path | |
import shutil | |
def copy_file(item, sou_dir, des_dir, type): | |
(filepath, filename) = os.path.split(item) | |
if type == os.path.splitext(filename)[1]: |
This file contains 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
#convert files to UTF8 encoding | |
#tested under Python3 | |
from chardet.universaldetector import UniversalDetector | |
import os | |
import os.path | |
def convert_to_uft8(filename, filetype, out_enc='utf-8'): | |
(filepath, name) = os.path.split(filename) | |
if filetype == os.path.splitext(name)[1]: | |
try: |
This file contains 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
#include <iostream> | |
#include <string> | |
#include <sstream> | |
int main() | |
{ | |
using namespace std; | |
string txt("nanonawefawefawefnaoawfnanowfawe"); | |
string pat("nano"); | |
stringstream stxt(txt); |
This file contains 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 main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. |
This file contains 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
import os | |
import os.path | |
import fnmatch | |
import logging | |
import ycm_core | |
BASE_FLAGS = [ | |
'-Wall', | |
'-Wextra', | |
'-Werror', |
This file contains 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
1 reorders detected after 11199 iterations | |
2 reorders detected after 12680 iterations | |
3 reorders detected after 58064 iterations | |
4 reorders detected after 69153 iterations | |
5 reorders detected after 72177 iterations | |
6 reorders detected after 72555 iterations | |
7 reorders detected after 75906 iterations | |
8 reorders detected after 95847 iterations | |
9 reorders detected after 98174 iterations | |
10 reorders detected after 103919 iterations |
OlderNewer