A. Exclusive "or" (xor) Logical Operator

Xotira: 32 MB, Vaqt: 1000 ms
Masala

Overview

In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns true if exactly one of the two expressions are true, false otherwise.

Kiruvchi ma'lumotlar:

2 bool element

Chiquvchi ma'lumotlar:

Result

Izoh:

Since we cannot define keywords in Javascript (well, at least I don't know how to do it), your task is to define a function xor(a, b) where a and b are the two expressions to be evaluated. Your xor function should have the behaviour described above, returning true if exactly one of the two expressions evaluate to true, false otherwise.

Misollar:
# INPUT.TXT OUTPUT.TXT
1
true true
false

B. Powers of 2

Xotira: 32 MB, Vaqt: 1000 ms
Masala

Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to n ( inclusive ).

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Misollar:
# INPUT.TXT OUTPUT.TXT
1
0
1
2
2
1 2 4

C. Is it even?

Xotira: 32 MB, Vaqt: 1000 ms
Masala

In this Kata we are passing a number (n) into a function.

Your code will determine if the number passed is even (or not).

The function needs to return either a true or false.

Numbers may be positive or negative, integers or floats.

Floats with decimal part non equal to zero are considered UNeven for this kata.


 

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Misollar:
# INPUT.TXT OUTPUT.TXT
1
0.5
false

D. Remove exclamation marks

Xotira: 32 MB, Vaqt: 1000 ms
Masala

Write function RemoveExclamationMarks which removes all exclamation marks from a given string.

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Misollar:
# INPUT.TXT OUTPUT.TXT
1
Hello World!
Hello World

E. Highest Scoring Word

Xotira: 32 MB, Vaqt: 1000 ms
Masala

Given a string of words, you need to find the highest scoring word.

Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.

For example, the score of abad is 8 (1 + 2 + 1 + 4).

You need to return the highest scoring word as a string.

If two words score the same, return the word that appears earliest in the original string.

All letters will be lowercase and all inputs will be valid.

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Misollar:
# INPUT.TXT OUTPUT.TXT
1
take me to semynak
semynak

F. Challenge Fun #10: Integer Square Root

Xotira: 32 MB, Vaqt: 1000 ms
Masala

For each given a number N, the integer S is called integer square root of N if S x S <= N and (S+1) x (S+1) > N.

In other words, S = Math.floor(Math.sqrt(N))

Your task is to calculate the integer square root of a given Number.

Note: Input is given in string format. That is, the Number may be very very large ;-)

Kiruvchi ma'lumotlar:
  • [input] string Number

number in decimal form. 0 < Number < 10^100

Chiquvchi ma'lumotlar:
  • [output] a string

integer squareroot of Number.

Misollar:
# INPUT.TXT OUTPUT.TXT
1
1
1
2
5
2
3
100
10

G. Persistent Bugger.

Xotira: 32 MB, Vaqt: 1000 ms
Masala

Write a function, persistence, that takes in a positive parameter num and returns its multiplicative persistence, which is the number of times you must multiply the digits in num until you reach a single digit.

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Izoh:

For example (Input --> Output):

39 --> 3 (because 3*9 = 27, 2*7 = 14, 1*4 = 4 and 4 has only one digit)
999 --> 4 (because 9*9*9 = 729, 7*2*9 = 126, 1*2*6 = 12, and finally 1*2 = 2)
4 --> 0 (because 4 is already a one-digit number)
Misollar:
# INPUT.TXT OUTPUT.TXT
1
39
3
2
999
4
3
4
0

H. Descending Order

Xotira: 32 MB, Vaqt: 1000 ms
Masala

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.

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Misollar:
# INPUT.TXT OUTPUT.TXT
1
0
0
2
1
1

I. Count the smiley faces!

Xotira: 32 MB, Vaqt: 1000 ms
Masala

Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces.

Rules for a smiling face:

  • Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ;
  • A smiley face can have a nose but it does not have to. Valid characters for a nose are - or ~
  • Every smiling face must have a smiling mouth that should be marked with either ) or D

No additional characters are allowed except for those mentioned.

Valid smiley face examples: :) :D ;-D :~)
Invalid smiley faces: ;( :> :} :]

Kiruvchi ma'lumotlar:
Chiquvchi ma'lumotlar:
Misollar:
# INPUT.TXT OUTPUT.TXT
Kitob yaratilingan sana: 22-Feb-25 19:03