Skip to content

Instantly share code, notes, and snippets.

View jinglescode's full-sized avatar
🎯
stay focus

Hong Jing (Jingles) jinglescode

🎯
stay focus
View GitHub Profile
/*
Project Euler: Problem 8: Largest product in a series
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.
Find the `n` adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?
*/
class Tester {
constructor(func_call, test_values) {
this.timer_start = performance.now();
this.timer_end = performance.now();
/*
Project Euler: Problem 7: 10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the nth prime number?
*/
// list of numbers we wanna test
var test_values = [6, 10, 100, 1000, 10001];
// this function execute the code and records the time to execute
/*
Project Euler: Problem 6: Sum square differencePassed
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
/*
Project Euler: Problem 5: Smallest multiplePassed
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to n?
*/
// list of numbers we wanna test
var test_values = [5, 7, 10, 13, 20];
// this function execute the code and records the time to execute
/*
Project Euler: Problem 4: Largest palindrome productPassed
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two n-digit numbers.
*/
// list of numbers we wanna test
var test_values = [2, 3];
// this function execute the code and records the time to execute
/*
Project Euler: Problem 3: Largest prime factorPassed
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the given number?
*/
// list of numbers we wanna test
var test_values = [2, 3, 5, 7, 13195, 600851475143];
// this function execute the code and records the time to execute
/*
Project Euler: Problem 2: Even Fibonacci NumbersPassed
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 sequence that do not exceed the nth term, find the sum of the even-valued terms.
*/
var test_values = [10, 18, 23, 43];
function run_function(func, test_values) {
/*
Project Euler: Problem 1: Multiples of 3 and 5Passed
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below the provided parameter value number.
*/
var test_number = 1000;
function run_function(func) {
var t0 = performance.now();
# KMeans
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=int(num_days), random_state=0).fit(places_lat_long)
group = list(kmeans.labels_)
# MeanShift
from sklearn.cluster import MeanShift, estimate_bandwidth
bandwidth = estimate_bandwidth(places_lat_long, quantile=0.2)
clustering = MeanShift(bandwidth=bandwidth).fit(places_lat_long)
group = clustering.labels_