Solved


Compute the sum of distances from a point to the sides of an equilateral triangle
Write a function to compute the sum of the (shortest) distances from a point inside an equilateral triangle to the sides of the ...

4 months ago

Solved


Construct numbers from antidiagonals of stacks of binary numbers
A sequence is constructed in the following way: Express the numbers 1, 2, 3, 4, 5,… in binary and stack them, right-justified. T...

4 months ago

Solved


List lunar triangular numbers without duplication
Triangular numbers—which are the subject of Cody Problems 5, 291, 44289, 44732, 45833, 55680, 55695, and 55705—are the sums of c...

4 months ago

Solved


Determine whether a number is a Higgs prime
If the sequence lists the Higgs primes, then is the smallest prime greater than such that divides the product . The first fo...

4 months ago

Solved


Compute the water table in a layered unconfined aquifer
Write a function to compute the flow per unit width and the elevation of the water table above the bottom of unconfined aquifer ...

4 months ago

Solved


Find the smallest number leading to a maximal product of two numbers that concatenate to another number
Cody Problem 58971 involves the maximal product of numbers that concatenate to a number . For example, if , then the products ar...

4 months ago

Solved


Compute the maximal product of any two numbers whose concatenation is n
Write a function that takes an input and computes the maximal product of numbers that concatenate to . For example, if , then t...

4 months ago

Solved


Find the nine-point circle of a triangle
Cody Problem 1336 asks us to find the circle that circumscribes a triangle, and Cody Problem 58354 asks us to find the circle th...

4 months ago

Solved


Count collisions in an idealized block system
Two blocks, which have masses and , slide along a frictionless, semi-infinite track bounded by a stationary wall. Initially blo...

4 months ago

Solved


Find the altitudes of a triangle
Write a function that takes the x- and y-coordinates of three points describing the vertices of a triangle and returns the coord...

4 months ago

Solved


Determine whether a number is prome
In discussing the unique factorization of numbers in Elementary Number Theory, Underwood Dudley devised a new number system: “C...

4 months ago

Solved


Classify water surface profiles
Problem statement Write a function to classify the water surface profile starting at depth in a channel with longitudinal slop...

4 months ago

Solved


List numbers that cannot be expressed as the sum of fewer than four squares
Lagrange proved that all positive integers can be expressed as the sum of four squares. For example, 27 = 16 + 9 + 1 + 1. Howeve...

4 months ago

Solved


Find the circle inscribed in a triangle
Write a function that takes the x- and y-coordinates of three points describing the vertices of a triangle and returns the cente...

4 months ago

Solved


Compute the critical depth of a channel
Problem statement Write a function to compute the critical depth of a channel with discharge . The unit system will be specifie...

4 months ago

Solved


Compute the normal depth of a channel
For steady uniform flow in a channel of constant cross section and slope, the depth does not change with distance or time. In th...

4 months ago

Solved


Decode a message encrypted with the square root of 2
Cody Problem 58299 asks you to encrypt a message by changing all letters to uppercase and randomly choosing a position of the AS...

4 months ago

Solved


Encrypt a message with the square root of 2
Suppose you want to encrypt the word ‘TWIN’. The ASCII codes for the four letters are 84, 87, 73, and 78. If you consider the fr...

4 months ago

Solved


Find a number m such that 2m and the square of m have the same digit sum
The number has the property that and have the same digit sum. It is the seventh number, including zero, in the sequence of nu...

4 months ago

Solved


Determine the minimum number of swaps to sort a vector
Cody Problem 1401 asks us to sort a vector with the bubble sort algorithm and count the number of swaps needed. For example, to ...

4 months ago

Solved


Compute flow in a partially full pipe
Problem statement When does the maximum flow occur in a pipe? Intuition might suggest that it occurs when the pipe is flowing f...

4 months ago

Solved


Route a hydrograph through a river section with the Muskingum method
Problem statement Write a function that routes a hydrograph through a river section using the Muskingum method. The input to t...

4 months ago

Solved


Solve an ODE: draining tank
Write a function to compute the time to drain a cylindrical tank of diameter from an initial level to a level . The outflow oc...

4 months ago

Solved


Compute infiltration and runoff under constant precipitation with the Green-Ampt method
Problem statement Write a function that computes infiltration, depression storage, and runoff using the Green-Ampt method. It s...

4 months ago

Solved


Inscribe a circle in a triangle with a side of length equal to the circle’s circumference
A circle of radius is inscribed in a triangle with a side that has a length equal to the circle’s circumference. The center of ...

4 months ago

Solved


Determine whether a hydrograph is a unit hydrograph
A hydrograph describes the runoff response of a catchment or watershed to rainfall. It shows the runoff rate (or flow or discha...

4 months ago

Solved


Compute the average precipitation for a watershed using the Thiessen polygon method
Several methods are available for estimating the average precipitation for a watershed from a few observations at rain gauges. T...

4 months ago

Solved


Compute frequency factors for the normal distribution
In frequency analysis in hydrology, the streamflow corresponding to a specified exceedance probability (or return period ) can...

4 months ago

Solved


Determine flows of given probability using empirical frequency analysis
Write a function that takes as input observations of peak streamflow and exceedance probabilities expressed as percentages an...

4 months ago

Solved


Find patterns in subprime Fibonacci sequences
Lots of Cody problems involve Fibonacci and Collatz sequences. Fibonacci sequences start with two numbers, and later terms are c...

4 months ago

Load more