This file contains hidden or 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 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 |
This file contains hidden or 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
| """ | |
| # 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. |
This file contains hidden or 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
| """ | |
| # 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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 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) |
This file contains hidden or 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
| Aarhus | |
| Aaron | |
| Ababa | |
| aback | |
| abaft | |
| abandon | |
| abandoned | |
| abandoning | |
| abandonment | |
| abandons |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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
| (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 |