Skip to content

Instantly share code, notes, and snippets.

View lovasoa's full-sized avatar
🎯
Focusing

Ophir LOJKINE lovasoa

🎯
Focusing
View GitHub Profile
@lovasoa
lovasoa / myxa.cpp
Last active April 17, 2018 08:11
МУХА + МУХА = СЛОН
#include<iostream>
using namespace std;
// муха + муха = слон
int main() {
// Числа не могут начитаться с нуля.
// Поэтому муха >= 1000
// и слон = 2*муха содержит 4 числа, поэтому
// 2*муха <= 9999
// муха <= 4999
@lovasoa
lovasoa / 3388.hs
Last active April 12, 2018 11:58
Soit la liste de nombres [3,8,3,8]. En utilisant tous les nombres de cette, liste, uniquement ces nombres, et les opérations mathématiques usuelles (addition, multiplication, division, soustraction), trouver une manière d'obtenir le nombre 24
import Data.List
import Control.Monad
data Operation = Plus | Minus | Mul | Div deriving (Eq,Ord)
data Tree = Compute Operation Tree Tree | Leaf Rational deriving (Eq,Ord)
instance Show Tree where
show (Compute op a b) = "(" ++ (show a) ++ (show op) ++ (show b) ++")"
show (Leaf x) = show (fromRational x)
#include<iostream>
using namespace std;
bool is_mirror(int n) {
if (n<=0) return true;
int n1, n2;
cin >> n1;
if (n==1) return true;
bool inner_mirror = is_mirror(n-2);
@lovasoa
lovasoa / move_left.c
Last active March 31, 2018 13:17
Move an array to the left by n positions without allocating more memory
#include <stdio.h>
void swap(int *a, int *b) {
int tmp = *a; *a = *b; *b = tmp;
}
void move_left(int a[], size_t size, int n) {
n = ((n % (int)size) + size) % size;
size_t remaining_size = size;
for(size_t i=0; i<size-1; i++) {
@lovasoa
lovasoa / LogisticMap.ipynb
Created February 17, 2018 17:32
Logistic Map with numpy and matplotlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lovasoa
lovasoa / VectorMean.scala
Created February 15, 2018 13:43
spark UDAF for computing the mean of vectors
import org.apache.spark.ml.linalg.SQLDataTypes.VectorType
import org.apache.spark.ml.linalg.{Vector, Vectors}
import org.apache.spark.sql.Row
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction}
import org.apache.spark.sql.types._
class VectorMean extends UserDefinedAggregateFunction {
// This is the input fields for your aggregate function.
#!/bin/env python3
from pathlib import Path
import subprocess
import csv
import re
linterpath = Path("/mnt/c/Program Files (x86)/Linter/bin/")
inl = linterpath / "inl.exe"
loarel = linterpath / "loarel.exe"
@lovasoa
lovasoa / oddsportal.py
Last active February 5, 2018 00:30
Tennis match odds data extraction
#!/bin/env python3
from urllib.request import *
from urllib.parse import unquote
import json
import re
from pprint import pprint
match_url="http://www.oddsportal.com/tennis/france/french-open-mixed-doubles/groenefeld-anna-lena-farah-robert-dabrowski-gabriela-bopanna-rohan-Iqu25RYO/"
res=urlopen(match_url).read().decode("utf-8")
@lovasoa
lovasoa / ашотлинтер.bat
Created January 29, 2018 21:02
Ашот линтер
:: Avoids displaying the commands we execute
@ECHO OFF
:: Adds linter utilities to the path
SET PATH=%PATH%;C:\Program Files (x86)\Linter\bin
:: Creates a database table named people
set sqlstr=CREATE OR REPLACE TABLE people (id INTEGER PRIMARY KEY, name VARCHAR(1024));
echo %sqlstr% | inl -u SYSTEM/MANAGER -n Demo -t -q
:: generates the csv
del people.csv
PVector centerOrb, centerPup, speed;
// Durée autour du comportement en veille
int initial_time = 0;
int inactivity = 1000;
float rotation_inactivity = 0.003;
float last_active_angle = 0;
// Caractérisitques de l'oeil
int rOrb = 50;