This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TicTacToe Game | |
Given the board configuration of the tic tac toe game, determine if the board is in either of the | |
following states: empty, player1 wins, player2 wins, draw or intermediate. | |
The board is said to be in initial state if all the cells contain ‘-1’, | |
player1 uses ‘1’ as his coin and player2 uses ‘2’ as his coin. | |
The game is draw when the board is full and no one has won the game. | |
The game is in intermediate state when no one has won and board is not full | |
First finish up taking the inputs. Then apply logic to find state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
char str[20]; | |
scanf("%[^\n]s",str); | |
int *counter= (int*)calloc(26,sizeof(int)); | |
// int counter[26]={0}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from hashlib import sha256 | |
def coprime(a, b): | |
while b != 0: | |
a, b = b, a % b | |
return a | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
author: cYpHeR | |
Github: cypher-nullbyte | |
''' | |
# ----------------------- | |
# We assume that our input text is only lowercase string of alphabets without spaced | |
# LET US START | |
def Ceaser_encrypt(text,s): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*2D array using array of pointers to 1D_array(or block of linear memory) | |
--------------------------- | |
*/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int r,c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Water and Jugs | |
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs. | |
If z liters of water is measurable, you must have z liters of water contained within one or both buckets by the end. | |
Operations allowed: | |
Fill any of the jugs completely with water. | |
Empty any of the jugs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cipher text generation | |
Encryption is a security technique where the text message is converted into unreadable form called as Cipher text. | |
Generate a cipher text using polygraphic substitution method based on linear algebra. Each letter is represented by a number modulo 26. | |
To encrypt a message, each block of n letters (considered as an n-component vector) is multiplied by an invertible n × n matrix, against modulus 26. | |
The matrix used for encryption is the cipher key, and it should be chosen randomly from the set of invertible n × n matrices (modulo 26). | |
Generate a cipher text for a text message of 3 letter alphabet. Hence the key should be 3*3 matrix. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Crossy Roads | |
Given a array where index 0 represents the distance walked towards north index 1 represents the distance walked | |
towards west index 2 represents the distance walked towards south and index 3 represents the distance walled towards east | |
and index 4 represents the distance towards north ,index 5 represents the distance towards west and so on | |
Assume that you are initially at origin. Given the distances find out whether you’ll cross the path you walked before | |
Print Yes if they cross or else No |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chalk sticks | |
Ganesh has n chalk sticks of various lengths. He tries to build a square out of the chalk sticks he have. Given the length of n chalk sticks check whether he can build a square or not. Every chalk stick must be used | |
Example:- | |
Input:- [1,1,2,2,2] | |
Output:-Yes | |
Explanation:-As square of side length 2 can be formed from the given lengths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cryptography-II | |
A message containing letters from A-Z is being encoded to numbers using the following mapping way:'A' -> 1,'B' -> 2,'Z' -> 26 | |
Beyond that, now the encoded string can also contain the character '*', which can be treated as one of the numbers from 1 to 9. | |
Given the encoded message containing digits and the character '*', return the total number of ways to decode it. | |
For example, 1* has got 18 decoding possibilities as shown below | |
(i) 1* - 1 may be decoded as A and * can take values from 1 to 9 |
NewerOlder