text stringlengths 2 4.68M | id stringlengths 14 185 | metadata dict | __index_level_0__ int64 0 1.49k |
|---|---|---|---|
from __future__ import annotations
class IIRFilter:
r"""
N-Order IIR filter
Assumes working with float samples normalized on [-1, 1]
---
Implementation details:
Based on the 2nd-order function from
https://en.wikipedia.org/wiki/Digital_biquad_filter,
this generalized N-order functio... | Python/audio_filters/iir_filter.py/0 | {
"file_path": "Python/audio_filters/iir_filter.py",
"repo_id": "Python",
"token_count": 1692
} | 0 |
"""
The nqueens problem is of placing N queens on a N * N
chess board such that no queen can attack any other queens placed
on that chess board.
This means that one queen cannot have any other queen on its horizontal, vertical and
diagonal lines.
"""
from __future__ import annotations
solution = []
def is_safe(bo... | Python/backtracking/n_queens.py/0 | {
"file_path": "Python/backtracking/n_queens.py",
"repo_id": "Python",
"token_count": 1156
} | 1 |
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm
def binary_xor(a: int, b: int) -> str:
"""
Take in 2 integers, convert them to binary,
return a binary number that is the
result of a binary xor operation on the integers provided.
>>> binary_xor(25, 32)
'0b111001'
>>>... | Python/bit_manipulation/binary_xor_operator.py/0 | {
"file_path": "Python/bit_manipulation/binary_xor_operator.py",
"repo_id": "Python",
"token_count": 621
} | 2 |
#!/usr/bin/env python3
"""Provide the functionality to manipulate a single bit."""
def set_bit(number: int, position: int) -> int:
"""
Set the bit at position to 1.
Details: perform bitwise or for given number and X.
Where X is a number with all the bits – zeroes and bit on given
position – one.... | Python/bit_manipulation/single_bit_manipulation_operations.py/0 | {
"file_path": "Python/bit_manipulation/single_bit_manipulation_operations.py",
"repo_id": "Python",
"token_count": 933
} | 3 |
from __future__ import annotations
from collections.abc import Sequence
from typing import Literal
def compare_string(string1: str, string2: str) -> str | Literal[False]:
"""
>>> compare_string('0010','0110')
'0_10'
>>> compare_string('0110','1101')
False
"""
list1 = list(string1)
li... | Python/boolean_algebra/quine_mc_cluskey.py/0 | {
"file_path": "Python/boolean_algebra/quine_mc_cluskey.py",
"repo_id": "Python",
"token_count": 2090
} | 4 |
"""
https://en.wikipedia.org/wiki/Autokey_cipher
An autokey cipher (also known as the autoclave cipher) is a cipher that
incorporates the message (the plaintext) into the key.
The key is generated from the message in some automated fashion,
sometimes by selecting certain letters from the text or, more commonly,
by addi... | Python/ciphers/autokey.py/0 | {
"file_path": "Python/ciphers/autokey.py",
"repo_id": "Python",
"token_count": 1796
} | 5 |
"""
Wikipedia: https://en.wikipedia.org/wiki/Enigma_machine
Video explanation: https://youtu.be/QwQVMqfoB2E
Also check out Numberphile's and Computerphile's videos on this topic
This module contains function 'enigma' which emulates
the famous Enigma machine from WWII.
Module includes:
- enigma function
- showcase of f... | Python/ciphers/enigma_machine2.py/0 | {
"file_path": "Python/ciphers/enigma_machine2.py",
"repo_id": "Python",
"token_count": 3797
} | 6 |
"""
An RSA prime factor algorithm.
The program can efficiently factor RSA prime number given the private key d and
public key e.
Source: on page 3 of https://crypto.stanford.edu/~dabo/papers/RSA-survey.pdf
More readable source: https://www.di-mgt.com.au/rsa_factorize_n.html
large number can take minutes to factor, the... | Python/ciphers/rsa_factorization.py/0 | {
"file_path": "Python/ciphers/rsa_factorization.py",
"repo_id": "Python",
"token_count": 721
} | 7 |
"""
https://en.wikipedia.org/wiki/Image_texture
https://en.wikipedia.org/wiki/Co-occurrence_matrix#Application_to_image_analysis
"""
import imageio.v2 as imageio
import numpy as np
def root_mean_square_error(original: np.ndarray, reference: np.ndarray) -> float:
"""Simple implementation of Root Mean Squared Erro... | Python/computer_vision/haralick_descriptors.py/0 | {
"file_path": "Python/computer_vision/haralick_descriptors.py",
"repo_id": "Python",
"token_count": 6458
} | 8 |
"""Convert a Decimal Number to an Octal Number."""
import math
# Modified from:
# https://github.com/TheAlgorithms/Javascript/blob/master/Conversions/DecimalToOctal.js
def decimal_to_octal(num: int) -> str:
"""Convert a Decimal Number to an Octal Number.
>>> all(decimal_to_octal(i) == oct(i) for i
... ... | Python/conversions/decimal_to_octal.py/0 | {
"file_path": "Python/conversions/decimal_to_octal.py",
"repo_id": "Python",
"token_count": 522
} | 9 |
ROMAN = [
(1000, "M"),
(900, "CM"),
(500, "D"),
(400, "CD"),
(100, "C"),
(90, "XC"),
(50, "L"),
(40, "XL"),
(10, "X"),
(9, "IX"),
(5, "V"),
(4, "IV"),
(1, "I"),
]
def roman_to_int(roman: str) -> int:
"""
LeetCode No. 13 Roman to Integer
Given a roman num... | Python/conversions/roman_numerals.py/0 | {
"file_path": "Python/conversions/roman_numerals.py",
"repo_id": "Python",
"token_count": 767
} | 10 |
"""
Calculate the Product Sum from a Special Array.
reference: https://dev.to/sfrasica/algorithms-product-sum-from-an-array-dc6
Python doctests can be run with the following command:
python -m doctest -v product_sum.py
Calculate the product sum of a "special" array which can contain integers or nested
arrays. The pro... | Python/data_structures/arrays/product_sum.py/0 | {
"file_path": "Python/data_structures/arrays/product_sum.py",
"repo_id": "Python",
"token_count": 1116
} | 11 |
from copy import deepcopy
class FenwickTree:
"""
Fenwick Tree
More info: https://en.wikipedia.org/wiki/Fenwick_tree
"""
def __init__(self, arr: list[int] | None = None, size: int | None = None) -> None:
"""
Constructor for the Fenwick tree
Parameters:
arr (li... | Python/data_structures/binary_tree/fenwick_tree.py/0 | {
"file_path": "Python/data_structures/binary_tree/fenwick_tree.py",
"repo_id": "Python",
"token_count": 3270
} | 12 |
from __future__ import annotations
from collections.abc import Iterator
from dataclasses import dataclass
@dataclass
class TreeNode:
"""
A binary tree node has a value, left child, and right child.
Props:
value: The value of the node.
left: The left child of the node.
right: The ... | Python/data_structures/binary_tree/serialize_deserialize_binary_tree.py/0 | {
"file_path": "Python/data_structures/binary_tree/serialize_deserialize_binary_tree.py",
"repo_id": "Python",
"token_count": 1558
} | 13 |
from operator import delitem, getitem, setitem
import pytest
from data_structures.hashing.hash_map import HashMap
def _get(k):
return getitem, k
def _set(k, v):
return setitem, k, v
def _del(k):
return delitem, k
def _run_operation(obj, fun, *args):
try:
return fun(obj, *args), None
... | Python/data_structures/hashing/tests/test_hash_map.py/0 | {
"file_path": "Python/data_structures/hashing/tests/test_hash_map.py",
"repo_id": "Python",
"token_count": 1046
} | 14 |
from __future__ import annotations
from typing import Any
class ContainsLoopError(Exception):
pass
class Node:
def __init__(self, data: Any) -> None:
self.data: Any = data
self.next_node: Node | None = None
def __iter__(self):
node = self
visited = []
while node... | Python/data_structures/linked_list/has_loop.py/0 | {
"file_path": "Python/data_structures/linked_list/has_loop.py",
"repo_id": "Python",
"token_count": 785
} | 15 |
"""Queue represented by a Python list"""
from collections.abc import Iterable
from typing import Generic, TypeVar
_T = TypeVar("_T")
class QueueByList(Generic[_T]):
def __init__(self, iterable: Iterable[_T] | None = None) -> None:
"""
>>> QueueByList()
Queue(())
>>> QueueByList([... | Python/data_structures/queue/queue_by_list.py/0 | {
"file_path": "Python/data_structures/queue/queue_by_list.py",
"repo_id": "Python",
"token_count": 1626
} | 16 |
# @Author : ojas-wani
# @File : laplacian_filter.py
# @Date : 10/04/2023
import numpy as np
from cv2 import (
BORDER_DEFAULT,
COLOR_BGR2GRAY,
CV_64F,
cvtColor,
filter2D,
imread,
imshow,
waitKey,
)
from digital_image_processing.filters.gaussian_filter import gaussian_filter
def... | Python/digital_image_processing/filters/laplacian_filter.py/0 | {
"file_path": "Python/digital_image_processing/filters/laplacian_filter.py",
"repo_id": "Python",
"token_count": 1210
} | 17 |
"""
Finding the peak of a unimodal list using divide and conquer.
A unimodal array is defined as follows: array is increasing up to index p,
then decreasing afterwards. (for p >= 1)
An obvious solution can be performed in O(n),
to find the maximum of the array.
(From Kleinberg and Tardos. Algorithm Design.
Addison Wesl... | Python/divide_and_conquer/peak.py/0 | {
"file_path": "Python/divide_and_conquer/peak.py",
"repo_id": "Python",
"token_count": 549
} | 18 |
"""
The number of partitions of a number n into at least k parts equals the number of
partitions into exactly k parts plus the number of partitions into at least k-1 parts.
Subtracting 1 from each part of a partition of n into k parts gives a partition of n-k
into k parts. These two facts together are used for this alg... | Python/dynamic_programming/integer_partition.py/0 | {
"file_path": "Python/dynamic_programming/integer_partition.py",
"repo_id": "Python",
"token_count": 742
} | 19 |
"""
You have m types of coins available in infinite quantities
where the value of each coins is given in the array S=[S0,... Sm-1]
Can you determine number of ways of making change for n units using
the given types of coins?
https://www.hackerrank.com/challenges/coin-change/problem
"""
def dp_count(s, n):
"""
... | Python/dynamic_programming/minimum_coin_change.py/0 | {
"file_path": "Python/dynamic_programming/minimum_coin_change.py",
"repo_id": "Python",
"token_count": 453
} | 20 |
from typing import Any
def viterbi(
observations_space: list,
states_space: list,
initial_probabilities: dict,
transition_probabilities: dict,
emission_probabilities: dict,
) -> list:
"""
Viterbi Algorithm, to find the most likely path of
states from the start and the expected ... | Python/dynamic_programming/viterbi.py/0 | {
"file_path": "Python/dynamic_programming/viterbi.py",
"repo_id": "Python",
"token_count": 5966
} | 21 |
# https://en.wikipedia.org/wiki/Ohm%27s_law
from __future__ import annotations
def ohms_law(voltage: float, current: float, resistance: float) -> dict[str, float]:
"""
Apply Ohm's Law, on any two given electrical values, which can be voltage, current,
and resistance, and then in a Python dict return name/... | Python/electronics/ohms_law.py/0 | {
"file_path": "Python/electronics/ohms_law.py",
"repo_id": "Python",
"token_count": 535
} | 22 |
# https://www.investopedia.com
from __future__ import annotations
def simple_interest(
principal: float, daily_interest_rate: float, days_between_payments: float
) -> float:
"""
>>> simple_interest(18000.0, 0.06, 3)
3240.0
>>> simple_interest(0.5, 0.06, 3)
0.09
>>> simple_interest(18000.0... | Python/financial/interest.py/0 | {
"file_path": "Python/financial/interest.py",
"repo_id": "Python",
"token_count": 1501
} | 23 |
from math import atan, cos, radians, sin, tan
from .haversine_distance import haversine_distance
AXIS_A = 6378137.0
AXIS_B = 6356752.314245
EQUATORIAL_RADIUS = 6378137
def lamberts_ellipsoidal_distance(
lat1: float, lon1: float, lat2: float, lon2: float
) -> float:
"""
Calculate the shortest distance al... | Python/geodesy/lamberts_ellipsoidal_distance.py/0 | {
"file_path": "Python/geodesy/lamberts_ellipsoidal_distance.py",
"repo_id": "Python",
"token_count": 1356
} | 24 |
"""
https://en.wikipedia.org/wiki/Breadth-first_search
pseudo-code:
breadth_first_search(graph G, start vertex s):
// all nodes initially unexplored
mark s as explored
let Q = queue data structure, initialized with s
while Q is non-empty:
remove the first node of Q, call it v
for each edge(v, w): // for w in g... | Python/graphs/breadth_first_search_2.py/0 | {
"file_path": "Python/graphs/breadth_first_search_2.py",
"repo_id": "Python",
"token_count": 983
} | 25 |
from collections import deque
from math import floor
from random import random
from time import time
# the default weight is 1 if not assigned but all the implementation is weighted
class DirectedGraph:
def __init__(self):
self.graph = {}
# adding vertices and edges
# adding the weight is option... | Python/graphs/directed_and_undirected_(weighted)_graph.py/0 | {
"file_path": "Python/graphs/directed_and_undirected_(weighted)_graph.py",
"repo_id": "Python",
"token_count": 9249
} | 26 |
"""
An implementation of Karger's Algorithm for partitioning a graph.
"""
from __future__ import annotations
import random
# Adjacency list representation of this graph:
# https://en.wikipedia.org/wiki/File:Single_run_of_Karger%E2%80%99s_Mincut_algorithm.svg
TEST_GRAPH = {
"1": ["2", "3", "4", "5"],
"2": ["1... | Python/graphs/karger.py/0 | {
"file_path": "Python/graphs/karger.py",
"repo_id": "Python",
"token_count": 1168
} | 27 |
"""
This algorithm (k=33) was first reported by Dan Bernstein many years ago in comp.lang.c
Another version of this algorithm (now favored by Bernstein) uses xor:
hash(i) = hash(i - 1) * 33 ^ str[i];
First Magic constant 33:
It has never been adequately explained.
It's magic because it works better tha... | Python/hashes/djb2.py/0 | {
"file_path": "Python/hashes/djb2.py",
"repo_id": "Python",
"token_count": 335
} | 28 |
import unittest
import pytest
from knapsack import greedy_knapsack as kp
class TestClass(unittest.TestCase):
"""
Test cases for knapsack
"""
def test_sorted(self):
"""
kp.calc_profit takes the required argument (profit, weight, max_weight)
and returns whether the answer matc... | Python/knapsack/tests/test_greedy_knapsack.py/0 | {
"file_path": "Python/knapsack/tests/test_greedy_knapsack.py",
"repo_id": "Python",
"token_count": 1016
} | 29 |
import unittest
import numpy as np
import pytest
def schur_complement(
mat_a: np.ndarray,
mat_b: np.ndarray,
mat_c: np.ndarray,
pseudo_inv: np.ndarray | None = None,
) -> np.ndarray:
"""
Schur complement of a symmetric matrix X given as a 2x2 block matrix
consisting of matrices A, B and C... | Python/linear_algebra/src/schur_complement.py/0 | {
"file_path": "Python/linear_algebra/src/schur_complement.py",
"repo_id": "Python",
"token_count": 1409
} | 30 |
import numpy as np
from sklearn.datasets import load_iris
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeRegressor
class GradientBoostingClassifier:
def __init__(self, n_estimators: int = 100, learning_rate: float = 0.1) -> None... | Python/machine_learning/gradient_boosting_classifier.py/0 | {
"file_path": "Python/machine_learning/gradient_boosting_classifier.py",
"repo_id": "Python",
"token_count": 1810
} | 31 |
from sklearn.neural_network import MLPClassifier
X = [[0.0, 0.0], [1.0, 1.0], [1.0, 0.0], [0.0, 1.0]]
y = [0, 1, 0, 0]
clf = MLPClassifier(
solver="lbfgs", alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1
)
clf.fit(X, y)
test = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0]]
Y = clf.predict(test)
def wrapper(y):
... | Python/machine_learning/multilayer_perceptron_classifier.py/0 | {
"file_path": "Python/machine_learning/multilayer_perceptron_classifier.py",
"repo_id": "Python",
"token_count": 240
} | 32 |
"""
In a multi-threaded download, this algorithm could be used to provide
each worker thread with a block of non-overlapping bytes to download.
For example:
for i in allocation_list:
requests.get(url,headers={'Range':f'bytes={i}'})
"""
from __future__ import annotations
def allocation_num(number_of_bytes... | Python/maths/allocation_number.py/0 | {
"file_path": "Python/maths/allocation_number.py",
"repo_id": "Python",
"token_count": 632
} | 33 |
def chebyshev_distance(point_a: list[float], point_b: list[float]) -> float:
"""
This function calculates the Chebyshev distance (also known as the
Chessboard distance) between two n-dimensional points represented as lists.
https://en.wikipedia.org/wiki/Chebyshev_distance
>>> chebyshev_distance([1... | Python/maths/chebyshev_distance.py/0 | {
"file_path": "Python/maths/chebyshev_distance.py",
"repo_id": "Python",
"token_count": 302
} | 34 |
# Eulers Totient function finds the number of relative primes of a number n from 1 to n
def totient(n: int) -> list:
"""
>>> n = 10
>>> totient_calculation = totient(n)
>>> for i in range(1, n):
... print(f"{i} has {totient_calculation[i]} relative primes.")
1 has 0 relative primes.
2 ha... | Python/maths/eulers_totient.py/0 | {
"file_path": "Python/maths/eulers_totient.py",
"repo_id": "Python",
"token_count": 545
} | 35 |
"""
== Liouville Lambda Function ==
The Liouville Lambda function, denoted by λ(n)
and λ(n) is 1 if n is the product of an even number of prime numbers,
and -1 if it is the product of an odd number of primes.
https://en.wikipedia.org/wiki/Liouville_function
"""
# Author : Akshay Dubey (https://github.com/itsAkshayDub... | Python/maths/liouville_lambda.py/0 | {
"file_path": "Python/maths/liouville_lambda.py",
"repo_id": "Python",
"token_count": 500
} | 36 |
from collections.abc import Callable
def bisection(function: Callable[[float], float], a: float, b: float) -> float:
"""
finds where function becomes 0 in [a,b] using bolzano
>>> bisection(lambda x: x ** 3 - 1, -5, 5)
1.0000000149011612
>>> bisection(lambda x: x ** 3 - 1, 2, 1000)
Traceback (m... | Python/maths/numerical_analysis/bisection.py/0 | {
"file_path": "Python/maths/numerical_analysis/bisection.py",
"repo_id": "Python",
"token_count": 721
} | 37 |
def perfect_cube(n: int) -> bool:
"""
Check if a number is a perfect cube or not.
>>> perfect_cube(27)
True
>>> perfect_cube(4)
False
"""
val = n ** (1 / 3)
return (val * val * val) == n
def perfect_cube_binary_search(n: int) -> bool:
"""
Check if a number is a perfect cub... | Python/maths/perfect_cube.py/0 | {
"file_path": "Python/maths/perfect_cube.py",
"repo_id": "Python",
"token_count": 565
} | 38 |
"""
Created on Thu Oct 5 16:44:23 2017
@author: Christian Bender
This Python library contains some useful functions to deal with
prime numbers and whole numbers.
Overview:
is_prime(number)
sieve_er(N)
get_prime_numbers(N)
prime_factorization(number)
greatest_prime_factor(number)
smallest_prime_factor(number)
get_p... | Python/maths/primelib.py/0 | {
"file_path": "Python/maths/primelib.py",
"repo_id": "Python",
"token_count": 8106
} | 39 |
"""
This is a pure Python implementation of the P-Series algorithm
https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#P-series
For doctests run following command:
python -m doctest -v p_series.py
or
python3 -m doctest -v p_series.py
For manual testing run:
python3 p_series.py
"""
from __future__ import annota... | Python/maths/series/p_series.py/0 | {
"file_path": "Python/maths/series/p_series.py",
"repo_id": "Python",
"token_count": 591
} | 40 |
def is_happy_number(number: int) -> bool:
"""
A happy number is a number which eventually reaches 1 when replaced by the sum of
the square of each digit.
:param number: The number to check for happiness.
:return: True if the number is a happy number, False otherwise.
>>> is_happy_number(19)
... | Python/maths/special_numbers/happy_number.py/0 | {
"file_path": "Python/maths/special_numbers/happy_number.py",
"repo_id": "Python",
"token_count": 514
} | 41 |
"""
Calculates the nth number in Sylvester's sequence
Source:
https://en.wikipedia.org/wiki/Sylvester%27s_sequence
"""
def sylvester(number: int) -> int:
"""
:param number: nth number to calculate in the sequence
:return: the nth number in Sylvester's sequence
>>> sylvester(8)
113423713055... | Python/maths/sylvester_sequence.py/0 | {
"file_path": "Python/maths/sylvester_sequence.py",
"repo_id": "Python",
"token_count": 443
} | 42 |
# https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-two-variables
# https://en.wikipedia.org/wiki/Cramer%27s_rule
def cramers_rule_2x2(equation1: list[int], equation2: list[int]) -> tuple[float, float]:
"""
Solves the system of linear equation in 2 variables.
:param: equation1: list of ... | Python/matrix/cramers_rule_2x2.py/0 | {
"file_path": "Python/matrix/cramers_rule_2x2.py",
"repo_id": "Python",
"token_count": 1347
} | 43 |
"""
Testing here assumes that numpy and linalg is ALWAYS correct!!!!
If running from PyCharm you can place the following line in "Additional Arguments" for
the pytest run configuration
-vv -m mat_ops -p no:cacheprovider
"""
import logging
# standard libraries
import sys
import numpy as np
import pytest # type: ign... | Python/matrix/tests/test_matrix_operation.py/0 | {
"file_path": "Python/matrix/tests/test_matrix_operation.py",
"repo_id": "Python",
"token_count": 1880
} | 44 |
"""
Squareplus Activation Function
Use Case: Squareplus designed to enhance positive values and suppress negative values.
For more detailed information, you can refer to the following link:
https://en.wikipedia.org/wiki/Rectifier_(neural_networks)#Squareplus
"""
import numpy as np
def squareplus(vector: np.ndarray,... | Python/neural_network/activation_functions/squareplus.py/0 | {
"file_path": "Python/neural_network/activation_functions/squareplus.py",
"repo_id": "Python",
"token_count": 410
} | 45 |
"""
This is a pure Python implementation of the Graham scan algorithm
Source: https://en.wikipedia.org/wiki/Graham_scan
For doctests run following command:
python3 -m doctest -v graham_scan.py
"""
from __future__ import annotations
from collections import deque
from enum import Enum
from math import atan2, degrees
f... | Python/other/graham_scan.py/0 | {
"file_path": "Python/other/graham_scan.py",
"repo_id": "Python",
"token_count": 2295
} | 46 |
def apply_table(inp, table):
"""
>>> apply_table("0123456789", list(range(10)))
'9012345678'
>>> apply_table("0123456789", list(range(9, -1, -1)))
'8765432109'
"""
res = ""
for i in table:
res += inp[i - 1]
return res
def left_shift(data):
"""
>>> left_shift("012345... | Python/other/sdes.py/0 | {
"file_path": "Python/other/sdes.py",
"repo_id": "Python",
"token_count": 1248
} | 47 |
"""
The root-mean-square speed is essential in measuring the average speed of particles
contained in a gas, defined as,
-----------------
| Vrms = √3RT/M |
-----------------
In Kinetic Molecular Theory, gasified particles are in a condition of constant random
motion; each particle moves at a completely different pa... | Python/physics/rms_speed_of_molecule.py/0 | {
"file_path": "Python/physics/rms_speed_of_molecule.py",
"repo_id": "Python",
"token_count": 583
} | 48 |
"""
Project Euler Problem 2: https://projecteuler.net/problem=2
Even Fibonacci Numbers
Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequenc... | Python/project_euler/problem_002/sol1.py/0 | {
"file_path": "Python/project_euler/problem_002/sol1.py",
"repo_id": "Python",
"token_count": 375
} | 49 |
"""
Project Euler Problem 6: https://projecteuler.net/problem=6
Sum square difference
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of... | Python/project_euler/problem_006/sol1.py/0 | {
"file_path": "Python/project_euler/problem_006/sol1.py",
"repo_id": "Python",
"token_count": 391
} | 50 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 9