Coder Social home page Coder Social logo

dev_school_homework's People

Contributors

arvxtyt avatar fayoni avatar

Watchers

 avatar

dev_school_homework's Issues

homework1

First task

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.

Finish the solution so that it returns the sum of all the multiples of 3
or 5 below the number passed in.

Additionally, if the number is negative, return 0.

Note: If the number is a multiple of both 3 and 5, only count it once.

Second task

Your task, is to calculate the minimal number of moves to win the game
"Towers of Hanoi", with given number of disks.

Towers of Hanoi is a simple game consisting of three rods, and a number
of disks of different sizes which can slide onto any rod. The puzzle
starts with the disks in a neat stack in ascending order of size on one
rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod,
obeying the following simple rules:

Only one disk can be moved at a time.
Each move consists of taking the upper disk from one of the stacks and
placing it on top of another stack i.e. a disk can only be moved if it
is the uppermost disk on a stack.
No disk may be placed on top of a smaller disk.

Third task

Your task is to construct a building which will be a pile of n cubes.
The cube at the bottom will have a volume of n^3, the cube above will
have volume of (nโˆ’1)^3 and so on until the top which will have a volume
of 1^3.

You are given the total volume m of the building. Being given m can you
find the number n of cubes you will have to build?
The parameter of the function findNb (find_nb, find-nb, findNb, ...)
will be an integer m and you have to return the integer n such as n^3 +
(n-1)^3 + (n-2)^3 + ... + 1^3 = m if such a n exists or -1 if there is
no such n.

Examples:
findNb(1071225) --> 45
findNb(91716553919377) --> -1

Fourth task

Define a function that takes an integer argument and returns a logical
value true or false depending on if the integer is a prime.
Per Wikipedia, a prime number ( or a prime ) is a natural number greater
than 1 that has no positive divisors other than 1 and itself.
Requirements:

  • You can assume you will be given an integer input.
  • You can not assume that the integer will be only positive. You may be
    given negative numbers as well ( or 0 ).
  • NOTE on performance: There are no fancy optimizations required, but
    still the most trivial solutions might time out. Numbers go up to 2^31 (
    or similar, depending on language ). Looping all the way up to n, or
    n/2, will be too slow.

Example:
is_prime(1) /* false /
is_prime(2) /
true /
is_prime(-1) /
false */

Fifth task

In this little assignment you are given a string of space separated
numbers, and have to return the highest and lowest number.

Examples:
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"

All numbers are valid Int32, no need to validate them.
There will always be at least one number in the input string.
Output string must be two numbers separated by a single space, and
highest number is first.

Sixth task

Your task is to make a function that can take any non-negative integer
as an argument and return it with its digits in descending order.
Essentially, rearrange the digits to create the highest possible number.

Examples:
Input: 42145 Output: 54421
Input: 145263 Output: 654321
Input: 123456789 Output: 987654321

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.