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 <vector> | |
using namespace std; | |
int first_occurrence(double x, const vector<double>& v){ | |
if (v.size()==0) return -1; | |
int inici = 0, final = v.size()-1; | |
while (inici <= final) { | |
int m = (inici + final)/2; | |
if (v[m] < x) ini = m + 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
def sedas(n): | |
B, A = [], [True] * (n + 1) | |
for i in range(2, n + 1): | |
if A[i]: | |
B.append(i) | |
for j in range(i * i, n + 1, i): | |
A[j] = False | |
return B | |
while True: |
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
from math import floor, sqrt | |
ap=True | |
while True: | |
p=int(input()) | |
for i in range (2, floor(sqrt(p))+1): | |
if p%i==0: | |
ap=False | |
break | |
else: | |
ap=True |
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 <Wire.h> | |
#define BMP180_I2C_Adress 0x77 //Usually 0x77 | |
int p0 = 1013.25; //Pressure at sea level; used to calculate altitude | |
int i = 2; //Pressure precision setting: 0, 1, 2 or 3 (3 is broken right now. will fix.) | |
int AC1; | |
int AC2; | |
int AC3; | |
unsigned int AC4; |
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 <Wire.h> | |
#include <VirtualWire.h> | |
#define BMP180_I2C_Adress 0x77 //Usually 0x77 | |
//SCL at A4 | |
//SDA at A5 | |
int DataInPin = 4; //XY-MK-5V | |
int DataOutPin = 5; //XY-FST | |
int LEDsPin = 10; //LEDs strip |
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
x, y = var('x y') | |
T = 7.5 | |
P = [] | |
for A in [-10,..,10]: | |
for B in [-10,..,10]: | |
P.append(implicit_plot(y^2==x^3+A*x+B, (x, -T, T), (y, -T, T))) | |
animate(P) |
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
# -*- coding: utf-8 -*- | |
import os, platform | |
from tkinter import * | |
from tkinter import filedialog, messagebox | |
from os import walk | |
from tkinter import ttk | |
from time import sleep | |
global pathconfig |
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
function [ bankrolls ] = ruleta(bankrollI, stakeI,apostes) | |
%bankrollI: diners amb els que comences a jugar | |
%stakeI: valor de l'aposta mínima | |
%apostes: número d'apostes a fer | |
close all | |
bankrolls = [bankrollI]; | |
stake = stakeI; | |
for i = 1:apostes | |
bankrollI = bankrollI - stake; | |
bankrolls = [bankrolls bankrollI]; |
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
function DELTAHOURS(date1, date2) { | |
//Takes two strings in the format "January 1, 1970 at 00:00AM" and returns the time delta in hours | |
var starthour = new Date(); | |
var endhour = new Date(); | |
//Month | |
switch (date1.slice(0, date1.indexOf(" "))){ | |
case "January": | |
starthour.setMonth(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
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters | |
def start(bot, update): | |
update.message.reply_text('This bot reverses every message you send') | |
def help(bot, update): | |
update.message.reply_text('Need help? Fuck yourself') |