arvxtyt / dev_school_homework Goto Github PK
View Code? Open in Web Editor NEWHomework for Devschool of FICE
License: MIT License
Homework for Devschool of FICE
License: MIT License
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:
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.