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
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
#ipstack replace freegeoip :"(( | |
import urllib.request | |
import json | |
token = '' #get token on ipstack.com |
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 "atoi.h" | |
int main (int argc, char* argv[]) { | |
printf("%d\n", atoi(argv[1])); | |
return 0; | |
} |
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
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
from calc_parser import calc_parser | |
def evaluate(expression: list): | |
for i in range(len(expression)): | |
if expression[i] != '+' and expression[i] != '-' and expression[i] != '*' and expression[i] != '/': | |
if '.' in expression[i]: |
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 re | |
from bs4 import BeautifulSoup | |
from bs4 import SoupStrainer | |
import urllib.request | |
import ssl | |
import urllib.parse | |
import urllib.error | |
from PIL import Image | |
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 <stdio.h> | |
void main() { | |
int i; | |
int j; | |
for (i = 1; i < 10; i++) { | |
for (j = 1; j < 10; j++) | |
printf("%2d ", i*j); | |
putchar('\n'); | |
} |
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
(lambda x: [[print('%d X %d = %2d' % (j, i, i*j), end='\t' if j < x else '\n') for j in range(1, x+1)] for i in range(1, x + 1)])(9) | |
# Output: | |
# 1 X 1 = 1 2 X 1 = 2 3 X 1 = 3 4 X 1 = 4 5 X 1 = 5 6 X 1 = 6 7 X 1 = 7 8 X 1 = 8 9 X 1 = 9 | |
# 1 X 2 = 2 2 X 2 = 4 3 X 2 = 6 4 X 2 = 8 5 X 2 = 10 6 X 2 = 12 7 X 2 = 14 8 X 2 = 16 9 X 2 = 18 | |
# 1 X 3 = 3 2 X 3 = 6 3 X 3 = 9 4 X 3 = 12 5 X 3 = 15 6 X 3 = 18 7 X 3 = 21 8 X 3 = 24 9 X 3 = 27 | |
# 1 X 4 = 4 2 X 4 = 8 3 X 4 = 12 4 X 4 = 16 5 X 4 = 20 6 X 4 = 24 7 X 4 = 28 8 X 4 = 32 9 X 4 = 36 | |
# 1 X 5 = 5 2 X 5 = 10 3 X 5 = 15 4 X 5 = 20 5 X 5 = 25 6 X 5 = 30 7 X 5 = 35 8 X 5 = 40 9 X 5 = 45 | |
# 1 X 6 = 6 2 X 6 = 12 3 X 6 = 18 4 X 6 = 24 5 X 6 = 30 6 X 6 = 36 7 X 6 = 42 8 X 6 = 48 9 X 6 = 54 | |
# 1 X 7 = 7 2 X 7 = 14 3 X 7 = 21 4 X 7 = 28 5 X 7 = 35 6 X 7 = 42 7 X 7 = 49 8 X 7 = 56 9 X 7 = 63 | |
# 1 X 8 = 8 2 X 8 = 16 3 X 8 = 24 4 X 8 = 32 5 X 8 = 40 6 X 8 = 48 7 X 8 = 56 8 X 8 = 64 9 X 8 = 72 |
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
(lambda x, max_len: [[print('%{}d'.format(max_len) % (i + j) if i + j != 0 else ' ' * max_len, end=' ' if j < x else '\n') for j in range(0, x + 1)] for i in range(0, x + 1)])(9, 2) | |
# Output: | |
# 1 2 3 4 5 6 7 8 9 | |
# 1 2 3 4 5 6 7 8 9 10 | |
# 2 3 4 5 6 7 8 9 10 11 | |
# 3 4 5 6 7 8 9 10 11 12 | |
# 4 5 6 7 8 9 10 11 12 13 | |
# 5 6 7 8 9 10 11 12 13 14 | |
# 6 7 8 9 10 11 12 13 14 15 | |
# 7 8 9 10 11 12 13 14 15 16 |
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
#!/bin/bash | |
#Install sl package and enjoy! | |
while : | |
do | |
sl | |
done |
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 <vector> | |
template <class T> | |
void bubble_sort(std::vector<T> &vec) { | |
//Bubble Sort | |
T tmp; | |
for (unsigned int i = 0; i < vec.size(); i++) { | |
for (unsigned int j = 0; j < vec.size()-1; j++) { | |
if (vec[j] > vec[j+1]) { | |
tmp = vec[j]; |
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
# brute-force solution 1 | |
radius = float(input('Enter radius: ')) | |
square_radius = radius * radius | |
int_count = 0 | |
max_int = int(radius) | |
min_int = (-1) * max_int | |
for i in range(min_int, max_int + 1): | |
for j in range(min_int, max_int + 1): | |
if (i*i) + (j*j) <= square_radius: | |
int_count += 1 |
OlderNewer