Today’s exercise is somebody’s homework:

Given positive integers C and N, find N numbers that sum up to C and the difference between the highest and the lowest of these number should not be more than one. For example: with C = 26 and N = 7, the desired output is [4 4 4 4 4 3 3].

Your task is to write a program to solve the student’s homework. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Given a length-*n* list like (a b c d e), the rotations of the list are the *n* lists (a b c d e), (b c d e a), (c d e a b), (d e a b c), and (e a b c d), in any order.

Your task is to write a program that takes a list and returns its rotations. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Write a program that displays the digits from 1 to

nthen back down to 1; for instance, ifn= 5, the program should display 123454321. You are permitted to use only a single`for`

loop.

The questioner did not specify what should happen when *n* reaches 10, so we will specify 0 < *n* < 10.

Your task is to write the requested program; if you like, think of other ways to write that program. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Your task is to write a that converts a CSV file to HTML output; use whatever conventions make sense to you. When you are finished, you are welcome to read a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Your task is to write a program that performs a perfect shuffle and use it to determine how many perfect shuffles are required to return an *n*-card deck to its original order; how many perfect shuffles are required for a standard 52-card deck? When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Given a list of integers and a target integer, find all the pairs of integers in the list that sum to the target integer, or report that there are no such pairs.

Your task is to write a program to find pairs of integers that sum to a target; you should write three programs, with time complexities of O(*n*²), O(*n* log *n*), and O(*n*). When you are finished, you are welcome to read a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Given an array of integers sorted in non-decreasing order, return an array of the squares of each number, also sorted in non-decreasing order. For instance, given (-4 -1 0 3 10), the desired output is (0 1 9 16 100).

Your task is to write a program to compute the sorted squares of a sorted array. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Jason rings every multiple of 13 less than 500. He then crosses every multiple of 17 less than 500. How many numbers get both ringed and crossed?

The test is a multiple-choice examination with possible selections 10, 0, 1 and 4. The solution sheet shows the correct answer is 4. The questioner who posted this question was asking how to calculate the answer given on the solution sheet.

And here is another simple task:

Given positive integer

n< 10^{18}, find the sum of the integers from 1 ton, mod 10^{9}+ 7. Assume you are using a language that provides 64-bit arithmetic, so no intermediate results can be larger than 2^{64}.

Your task is to write a program to solve these two tasks. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>`abc`

has three rotations: `abc`

, `bca`

, and `cab`

.
Your task is to write a program that computes all the rotations of a string. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Your task is to write a program that counts the Pythagorian quadruples with *a*, *b*, *c* less than or equal to some given *N*, and compute the number of Pythagorian quadruples with *N* = 1000. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.