Find a Pythagorean triple
Given four different positive numbers, a, b, c and d, provided in increasing order: a < b < c < d, find if any three of them com...
Binary code (array)
Write a function which calculates the binary code of a number 'n' and gives the result as an array(vector).
Example:
Inpu...
3年弱 前
解決済み
Relative ratio of "1" in binary number
Input(n) is positive integer number
Output(r) is (number of "1" in binary input) / (number of bits).
Example:
* n=0; r=...
Bit Reversal
Given an unsigned integer _x_, convert it to binary with _n_ bits, reverse the order of the bits, and convert it back to an inte...
3年弱 前
解決済み
Find out sum and carry of Binary adder
Find out sum and carry of a binary adder if previous carry is given with two bits (x and y) for addition.
Examples
Previo...
Is this triangle right-angled?
Given any three positive numbers a, b, c, return true if the triangle with sides a, b and c is right-angled. Otherwise, return f...
Energy of an object
Calculate the total mechanical energy of an object.
Total Energy= Potential energy + Kinetic energy
P.E.=m*g*h
K.E.=1/2...
3年弱 前
解決済み
Longest run of consecutive numbers
Given a vector a, find the number(s) that is/are repeated consecutively most often. For example, if you have
a = [1 2 2 2 1 ...