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
#first | |
#- write recursive solution | |
coins = [50, 20, 10, 5, 1] | |
count =0 | |
count2 = 0 | |
def cc(a,d): | |
global count | |
count+=1 | |
if a <0 or d == 0: | |
return 0 |
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
Use % 100 to get the last two digits of a number | |
--- 430 % 100 => 30 | |
Use // 100 to get the first digit of a number | |
--- 430 //100 => 4 | |
Use % 10 to get the last digit of a number | |
--- 430 % 10 => 0 | |
Conclusion | |
- Use //10 to get from the left | |
//10, remove 1 digit from right | |
//100, remove 2 digits from right |
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
# Number of Combinations = 2**(length of input set) | |
# Makes use of binary | |
def PowerSet(input): | |
ans = [] | |
numOfComb = 2 ** len(input) | |
for combidx in range(numOfComb): # 0 -> numOfComb | |
temp = [] | |
for setidx in range(len(input)): # 0 -> len(input) | |
if combidx & 1 << setidx: # bitwise operation e.g. 0 & 1 << 0 =>0 | |
temp.append(input[setidx]) |
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
# You probably need to set a size that is way larger than expected file size, | |
# if not you still may receive this 413 Request entity too large error | |
server { | |
client_max_body_size 100M; | |
... | |
} | |
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 read_csv(filename): # provided | |
with open(filename, 'r') as f: | |
lines = csv.reader(f, delimiter=',') | |
return tuple(lines) |
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 make_datetime(string): # provided | |
string = string.split(' ') | |
date_str = string[0].split('/') | |
time_str = string[1].split(':') | |
date_int = [int(x) for x in date_str] | |
time_int = [int(x) for x in time_str] | |
return datetime.datetime(date_int[2], date_int[1], date_int[0], time_int[0], time_int[1]) |
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
# create virtual environment in this folder called env | |
python -m venv env | |
# activate it | |
env\Scripts\activate.bat |
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
https://serverfault.com/questions/110154/whats-the-default-superuser-username-password-for-postgres-after-a-new-install | |
In Windows, do the following (IMPORTANT: Use a Windows administrator account): | |
After installation, open <PostgreSQL PATH>\data\pg_hba.conf. | |
Modify these two lines, and change "md5" to "trust": | |
host all all 127.0.0.1/32 md5 | |
host all all ::1/128 md5 |
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
# remove local branch | |
git branch -d branchname |
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
https://www.makeareadme.com/ | |
# Foobar | |
Foobar is a Python library for dealing with word pluralization. | |
## Installation | |
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar. | |
```bash |
OlderNewer