Skip to content

Instantly share code, notes, and snippets.

View uroybd's full-sized avatar

Utsob Roy uroybd

View GitHub Profile
@uroybd
uroybd / Hackerrank e^x
Last active August 29, 2015 14:23
Hackerrank e^x
(loop [test-case-remaining (Integer/parseInt (read-line))]
(while (not= 0 test-case-remaining)
(do (println (let [factorial (fn [n]
(reduce * (take n (range 1 (inc n)))))
to-the-power (fn [n m]
(reduce * (repeat m n)))
e-to-the-power-x (fn [x]
(inc (apply + (map #(float (/ (to-the-power x %)
(factorial %)))
(range 1 10)))))]
@uroybd
uroybd / eular1.clj
Created August 12, 2015 04:47
multiplse of 3 and 5
(defn bigboy [x]
(reduce + (distinct (concat (take-nth 3 (range x)) (take-nth 5 (range x))))))
(loop [start 1 end (Integer/parseInt (read-line))]
(when (<= start end)
(println (bigboy (Integer/parseInt (read-line))))
(recur (inc start) end)))
@uroybd
uroybd / html-o-matic
Created August 16, 2015 08:52
Html Cleaner
(use 'pl.danieljanus.tagsoup)
(use 'hiccup.core)
(defn parser [file_path]
(pl.danieljanus.tagsoup/parse (java.io.ByteArrayInputStream. (.getBytes (slurp file_path)))))
(defn attr_filter [element]
(cond
(map? element) {}
(= (type []) (type element)) (mapv identity (map attr_filter element))
@uroybd
uroybd / html-o-matic
Created August 17, 2015 11:52
Filter html
(use 'pl.danieljanus.tagsoup)
(use 'hiccup.core)
(defn parser [input]
(pl.danieljanus.tagsoup/parse
(java.io.ByteArrayInputStream.
(.getBytes
(slurp input)))))
(defn dissoc-all [dmap keys]
@uroybd
uroybd / move.clj
Last active August 29, 2015 14:27
(defn move
([dvec direction indx]
(cond (= direction :up) (move dvec :swap indx (dec indx))
(= direction :down) (move dvec :swap indx (inc indx))
:else (println "Wrong Number of args")))
([dvec direction indx1 indx2]
(if (= direction :swap)
(assoc dvec indx2 (nth dvec indx1) indx1 (nth dvec indx2))
(println "Invalid arguments"))))
@uroybd
uroybd / LinearSearch.py
Last active June 22, 2016 09:21
Simplest linear search in python
def LinearSearch(item, array):
return True if item in array else False
@uroybd
uroybd / calc.py
Last active June 26, 2016 09:11
Calculator(Shortend from a code of a fellow member from pycharmers group)
import math
def get_num():
inp = input("Enter a number: ")
try:
return float(inp)
except:
print("Enter a valid number.")
get_num()
@uroybd
uroybd / solution.c
Created July 14, 2016 17:19
URI 1118
#include <stdio.h>
int main()
{
int r, c;
float n, s;
do{
c=0;
s=0.0;
while(c<2)
{
@uroybd
uroybd / uri.py
Created July 14, 2016 17:38
URI 1118 python
def get_input():
inp = float(input())
if inp > 10 or inp < 0:
print("nota invalida")
return get_input()
else:
return inp
def calculate():
a = get_input()
@uroybd
uroybd / triangle.py
Created July 16, 2016 17:34
Triangle
from itertools import combinations
def ifTri (a, b, c):
if a + b > c and b + c > a and c + a > b:
return True
else:
return False
inp = input().split(" ")
pool = []