This repository contains done programming exercises from various sources.
directory number_converter
https://pl.spoj.com/problems/TCONNUM/
Every integer number n is represented in positional number system of base r by a sequence of digits 0 ≤ di < r, so the value is equal to: n = d0 + r * d1 + r2 * d2 + r3 * d3 + ... Your task is to convert a given number in r-base represantation into s-base representation, for example: decimal 231 into binary 11100111. Assume that r ≤ 36 and the digits are 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z.
directory nww
https://pl.spoj.com/problems/NWW/
Given are n natural numbers a1, ..., an. Find the least common multiple of these numbers, i.e. the smallest natural number M such that for each i the number ai divides M without a remainder.
Entry The first line shows the number of tests.
For each test, the number n is given first, and then in the next line of the number a1 ..., an.
It can be assumed that both the numbers ai and the result are in the range [1..264-1].
directory dodawanie
This exercise was an external exercise. Given are 2 numbers of unlimited length. Add those numbers. Because of the unlimited length the numbers have to be converted from string to a number and then added digit by digit.
directory magical_colorful_cats
https://www.spoj.com/problems/BLCATS/
There is a circle of n cats, includes white cats, red cats and green cats. When two cats of different colors talk with each other, they both change to third color. If they have same color, nothing will happen.
At each step, the 1st cat talks with 2nd cat, the 2nd cat talks with the 3rd cat,… and the nth cat talks with 1st cat.
Given the original color of n cats, your task is find the color of n cats after k steps.
Input:
First line : n and k (1 ≤ n ≤ 50000, 1 ≤ k ≤ 109)
Second line : n characters, the i-th charater denotes color of the i-th cat at first state
Output:
n charaters denotes the color of n cats after k steps.
directory xor_cipher
https://edabit.com/challenge/nWfncGvPyxwBLz7rx
In XOR Cipher, encoding is done by an XOR operation on two given strings. If the strings are of different lengths then the output should be the length of the shorter string. Cut the length of the longer string to the same size as the smaller string before XOR operation.
Given two strings of msg1 and msg2, return the encoded message.
XORCipher("11", "22") ➞ "33" // 11 XOR 22 = 33
XORCipher("1020304", "403201") ➞ "501231"
XORCipher("c611d9bdd9de38b9eb", "23a0745505d4d25494") ➞ "e5b1ade8dc0aeaed7f"