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 create_directories(basepath, start_date, end_date, date_format='%Y%m%d'): | |
""" Creates all subdirectories under the specified path named after the specified dates, one for each date. | |
start_date and end_date are both datetime.date objects. | |
date_format is a format string for the date which will be used to name the directories. | |
Example: | |
create_directories('/home/myhome', date(2016, 01, 01), date(2016, 01, 03)) will create directories named 20160101, 20160102 and 20160103 within /home/myhome. | |
Directory structure is created recursively if it doesn't exist. | |
""" |
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
/** | |
Solution to the 'Substring Sum' problem: | |
Accept a string consisting of digits and return the number of possible groupings of digits such that | |
sum of digits of each grouping at the left is less than or equal to sum of digits of every grouping on the right (i.e. they are in ascending order). | |
For example: | |
String = "1337" | |
Groupings: "1,337"; "1,3,37"; "1,3,3,7"; "1,33,7"; "13,37"; "13,3,7"; "133,7" | |
@author Sagar Ahire | |
*/ | |
public class SubstringSum |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import sys | |
def split_line(line): | |
cols = line.split("\t") | |
return cols | |
def get_words(cols): | |
words_ids = cols[4].split(" ") | |
words = [w.split("#")[0] for w in words_ids] | |
return words |