Skip to content

Instantly share code, notes, and snippets.

View mvallebr's full-sized avatar

Marcelo Elias Del Valle mvallebr

View GitHub Profile
def primes_up_to(N):
sieve = N*[True]
for i in range(2, N):
if not sieve[i]: continue
yield i
for j in range(i*i, N, i):
sieve[j] = False
"""
# Expecto Palindronum
Memory Limit:64 MB
Time Limit: 5 s
A palindrome is a word that reads the same backward and forward.
Given a string S, you are allowed to convert it to a palindrome by adding 0 or more characters in front of it.
"""
# Expecto Palindronum
Memory Limit:64 MB
Time Limit: 5 s
A palindrome is a word that reads the same backward and forward.
Given a string S, you are allowed to convert it to a palindrome by adding 0 or more characters in front of it.
Find the length of the shortest palindrome that you can create from S by applying the above transformation.
## Input Specifications
Your program will take
A string S ( 1 ≤ Length(S) ≤ 100) where each character of S will be
@mvallebr
mvallebr / binConverter.py
Last active June 22, 2017 12:19 — forked from echiesse/binConverter.py
Exemplo de conversão de decimal para binário
num = int(input("Escolha um número decimal para transformar em binario: "))
result = []
zero = '0'
while num > 0:
num, bit = divmod(num, 2)
result.append(bit)
zero = ''
# Imprimir em ordem inversa
import Control.Applicative
import Control.Monad
import System.IO
import Text.Printf
eterm 0 n cf f cx x = 1 + (eterm 1 n 1 1 x x)
eterm cn n cf f cx x
| cn >= n = 0
| otherwise = (cx/cf) + (eterm (cn+1) n (cf * (f+1)) (f+1) (cx*x) x)
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
# Given a words.txt file containing a newline-delimited list of dictionary
# words, please implement the Anagrams class so that the get_anagrams() method
# returns all anagrams from words.txt for a given word.
#
# Bonus requirements:
# - Optimise the code for fast retrieval
# - Write more tests
# - Thread safe implementation
import unittest
import Control.Applicative
import Control.Monad
import System.IO
import Text.Printf
factorial :: Integer -> [Integer] -> [Integer]
factorial acc [] = []
factorial 0 (head:tail) = 1 : factorial (1 * head) tail
factorial acc (head:tail) = (head * acc) : factorial (head * acc) tail
import Text.Printf
expansion :: Double -> [Double]
expansion x = zipWith (/) powers factorials
where powers = iterate (*x) 1
factorials = scanl (*) 1 [1..]
e2x :: Double -> Double
e2x = sum . take 10 . expansion
(mqcapi) C02RC5G6G8WP:mqc_api mvallemilita$ docker build .
Sending build context to Docker daemon 171kB
Step 1/7 : FROM debian:latest
---> da653cee0545
Step 2/7 : RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages python3 python3-pip
---> Using cache
---> c0a3185b16fc
Step 3/7 : COPY requirements.txt /source/
---> Using cache
---> ade4b3f3961e