Resuelto


Remove the air bubbles
Given a matrix a, return a matrix b in which all the zeros have "bubbled" to the top. That is, any zeros in a given column shoul...

casi 3 años hace

Resuelto


Edges of a n-dimensional Hypercube
Return the number of edges on an <http://en.wikipedia.org/wiki/Hypercube _n_-dimensional hypercube> (with an integer n &ge; 0). ...

casi 3 años hace

Resuelto


Dots in a Sphere
Return how many integer grid points there are inside a 3D sphere of radius _r_ centred at (0,0,0) (including points on the edge)...

casi 3 años hace

Resuelto


Shifted Hexagonal Tiling Dots in a Circle
Return how many <http://en.wikipedia.org/wiki/Hexagonal_grid Hexagonal Tiling> grid points there are inside a circle of radius _...

casi 3 años hace

Resuelto


Dots in a Diamond
Return how many <http://en.wikipedia.org/wiki/Diamond_cubic Diamond Cubic> lattice grid points there are inside a 3D sphere of r...

casi 3 años hace

Resuelto


Crop an Image
A grayscale image is represented as a matrix in MATLAB. Each matrix element represents a pixel in the image. An element value re...

casi 3 años hace

Resuelto


Back to basics 23 - Triangular matrix
Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, return a matrix with all elements above a...

casi 3 años hace

Resuelto


Travelling Salesman Problem (TSP)
Find a short way through given points. This is the travelling salesman problem. But the solution should be a fast and small func...

casi 3 años hace

Resuelto


Compute the largest number with a given integer complexity
Cody Problems 42831 and 42834 ask us to compute integer complexity, the smallest number of 1s needed to construct a number with ...

casi 3 años hace

Resuelto


Determine if input is a Harshad number
In mathematics a harshad number (or Niven number) in a given number base is an integer that is divisible by the sum of its digit...

casi 3 años hace

Resuelto


Project Euler: Problem 11, Largest product in a grid
What is the greatest product of _k_ adjacent numbers in the same direction (up, down, left, right, or diagonally) in a _n×n_ gri...

más de 3 años hace

Resuelto


Create the Ulam spiral
Have you ever seen this wonderful spiral ? The Ulam Spiral is arranging prime numbers in a clockwise spiral starting in 0. Give...

más de 3 años hace

Resuelto


Get the n-th rand number with given seed
Given seed s, return the n-th rand number using rand(). Round the answer with 4 digits. n is a postive integer.

más de 3 años hace

Resuelto


Area of a regular hexagon
Given the length of a side of a regular hexagon, return its area rounded to two decimal places.

más de 3 años hace

Resuelto


Draw "T" inside a Zero Matrix
Given a x-by-x matrix filled with zeros (x> 2). Use 1 to draw a letter "T" into it! Like this: x = 5, y = 1 1 1 1 1 0 0 1 0 0...

más de 3 años hace

Resuelto


Add the number of horizontal and vertical movements to each matrix element
Given n, create a square matrix and with element (1,1) = 1, add 1 to each element for each horitizonal and vertical movement. E...

más de 3 años hace

Resuelto


Classify product/digit-sum sequences
Cody Problem 53120 involved a sequence in which a term is computed by multiplying the previous two terms and adding the digits o...

más de 3 años hace

Resuelto


Compute the Sequence of the Day
A sequence starts with 1 and 2, and each subsequent term is the sum of the digits of the product of the previous two terms. As a...

más de 3 años hace

Resuelto


Draw the symbol '+'
Draw '+' in an x-by-x matrix (where x is odd and x >3) Example: x = 5 y = [0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 ...

más de 3 años hace

Resuelto


Easy Sequences 30: Nearly Pythagorean Triangles
A Nearly Pythagorean Triangle (abbreviated as "NPT'), is an integer-sided triangle whose square of the longest side, which we wi...

casi 4 años hace

Resuelto


Easy Sequences 51: Positive Gaussian Primes
A Gaussian Prime is a gaussian integer that cannot be decomposed as product of two non-unit gaussian integers (the complex units...

casi 4 años hace

Resuelto


Easy Sequences 9: Faithful Pairs
A "faithful number" is a non-prime number that is one less or one more than some prime number but not both. For example, for num...

casi 4 años hace

Resuelto


Easy Sequences 58: Curious Prime-Rational Functions
For some prime numbers and where , a rational function , is defined as follows: . Using the output , another rational functi...

casi 4 años hace

Resuelto


Performance - summation
Given a vector of natural numbers x = [1,2,3,...,N] compute the sum of its elements by not stressing the machine too much...

casi 4 años hace

Resuelto


Probabilities - Balls and urns - 01
The urn contains B blue balls and R red balls. Each trial consists of drawing one random ball from the urn and observing its col...

casi 4 años hace

Resuelto


Easy Sequences 53: Greatest Proper Divisor
The greatest proper divisor () of an integer is the largest integer , such that and . Furthermore, we define: . Below is the...

casi 4 años hace

Resuelto


Easy Sequences 55: "Ugly" Rectangles?
A positive integer is called a regular number, if and only if there exist a non-negative integer , such that . For some reason...

casi 4 años hace

Resuelto


Easy Sequences 3: Prime 44-number Squares
The positive integers 62 and 238 are related. Their squares (3844 and 56,644) both end in '44'. In fact, 62 and 238 are the 3rd ...

casi 4 años hace

Resuelto


Easy Sequences 1: Find the index of an element
The nth element of a series is defined by: . Obviously, the first element . Given the nth element , find the value of the corre...

casi 4 años hace

Cargar más