Liking cljdoc? Tell your friends :D

advent-utils.math


gcdclj

(gcd a b)

Greatest common divisor between a and b

Greatest common divisor between a and b
sourceraw docstring

lcmclj

(lcm a b)
(lcm a b & others)

Least common multiple of a and b

Least common multiple of a and b
sourceraw docstring

manhattanclj

(manhattan [x1 y1] [x2 y2])

Computes the Manhattan distance between two points

Computes the Manhattan distance between two points
sourceraw docstring

mod-addclj

(mod-add m a b)

Computes a + b mod m

Computes a + b mod m
sourceraw docstring

mod-divclj

(mod-div m a b)

Computes a / b mod m Note that b^-1 does not always exist for all b for all m (b and m must be co-prime)

Computes a / b mod m
Note that b^-1 does not always exist for all b for all m (b and m must be co-prime)
sourceraw docstring

mod-geometric-sumclj

(mod-geometric-sum m a n)

The sum of the geometric sequence 1 + a + a^2 + ... + a^n, with all operations modulo m Formula from https://stackoverflow.com/questions/42032824/geometric-series-modulus-operation

The sum of the geometric sequence 1 + a + a^2 + ... + a^n, with all operations modulo m
Formula from https://stackoverflow.com/questions/42032824/geometric-series-modulus-operation
sourceraw docstring

mod-inverseclj

(mod-inverse m a)

Computes the multiplicative inverse of a, mod m

Computes the multiplicative inverse of a, mod m
sourceraw docstring

mod-linear-compclj

(mod-linear-comp _ x)
(mod-linear-comp m [a2 b2] [a1 b1])

Takes two linear functions of the form f(x) = a1x + b1 and g(x) = a2x + b2 (both modulo m), and determines the coefficients of the composite function (g(f(x)))

Takes two linear functions of the form f(x) = a1*x + b1 and g(x) = a2*x + b2 (both modulo m), and
determines the coefficients of the composite function (g(f(x)))
sourceraw docstring

mod-linear-inverseclj

(mod-linear-inverse m [a b])

Coefficients of the inverse of a linear function of the form (f(x) = a*x + b modulo m

Coefficients of the inverse of a linear function of the form (f(x) = a*x + b modulo m
sourceraw docstring

mod-linear-powclj

(mod-linear-pow m n [a b])

Determines the coefficients of the a linear function composed on itself multiple times, i.e., if f(x) = a*x + b, determines f^n(x) = f(f(f(f...(f(x))))) with n nestings

[a b]^n = [a^n (a^(n-1) + a^(n-2) + ... + a^1 + 1)b]

Should be equivalent to (first (drop n (iterate (partial mod-linear-comp m) [a b])))

Determines the coefficients of the a linear function composed on itself multiple times, i.e.,
if f(x) = a*x + b, determines f^n(x) = f(f(f(f...(f(x))))) with n nestings

[a b]^n = [a^n (a^(n-1) + a^(n-2) + ... + a^1 + 1)b]

Should be equivalent to (first (drop n (iterate (partial mod-linear-comp m) [a b])))
sourceraw docstring

mod-mulclj

(mod-mul m a b)

Computes a * b mod m

Computes a * b mod m
sourceraw docstring

mod-powclj

(mod-pow m a n)

Computes a^n mod m

Computes a^n mod m
sourceraw docstring

mod-pow-fastclj

(mod-pow-fast m a n)

Computes a^n mod m

Computes a^n mod m
sourceraw docstring

mod-subclj

(mod-sub m a b)

Computes a - b mod m

Computes a - b mod m
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close