# Introduction 

A grille cipher was a technique for encrypting a plaintext by writing it onto a sheet of paper through a pierced sheet (of paper or cardboard or similar). The earliest known description is due to the polymath Girolamo Cardano in 1550. His proposal was for a rectangular stencil allowing single letters, syllables, or words to be written, then later read, through its various apertures. The written fragments of the plaintext could be further disguised by filling the gaps between the fragments with anodyne words or letters. This variant is also an example of steganography, as are many of the grille ciphers. 
Wikipedia Link 

![Tangiers1](https://upload.wikimedia.org/wikipedia/commons/8/8a/Tangiers1.png)
![Tangiers2](https://upload.wikimedia.org/wikipedia/commons/b/b9/Tangiers2.png)

# Task

Write a function that accepts two inputs: `message` and `code` and returns hidden message decrypted from `message` using the `code`.   
The `code` is a nonnegative integer and it decrypts in binary the `message`.

Difficulty: EASY
Starter code: def grille(message, code):
	

Solutions:
def grille(msg, code):
	return ''.join((msg[-1 - i] for (i, c) in enumerate(bin(code)[::-1]) if c == '1' and i < len(msg)))[::-1]


def grille(message, code):
	binary = bin(code)[2:][-len(message):].zfill(len(message))
	return ''.join((char for (char, code) in zip(message, binary) if code == '1'))


def grille(m, c):
	return ''.join((i[0] for i in zip(m[::-1], bin(c)[2:][::-1]) if i[1] == '1'))[::-1]


def grille(message, code):
	binary = bin(code)[2:][::-1]
	return ''.join([j for (i, j) in enumerate(message[::-1]) if i < len(binary) and binary[i] == '1'])[::-1]


def grille(message, code):
	l = len(message)
	return ''.join((c for (c, b) in zip(message, f'{code:{l}b}'[-l:]) if b == '1'))


from itertools import compress

def grille(message, code):
	l = len(message)
	code = list(map(int, bin(code)[2:].zfill(l)))
	return ''.join(list(compress(message, [code, code[l:]][l < len(code)])))


from itertools import compress

def grille(message, code):
	n = len(message)
	grille = map(int, '{:0{}b}'.format(code, n)[-n:])
	return ''.join(compress(message, grille))


def grille(message, code):
	binary = str(bin(code)[2:].zfill(len(message)))
	print(str(bin(code)[2:]))
	i = 0
	decoded = ''
	if len(binary) > len(message):
		while i < len(message):
			if binary[i + (len(binary) - len(message))] == '1':
				decoded += message[i]
			i += 1
	while i < len(message):
		if binary[i] == '1':
			decoded += message[i]
		i += 1
	return decoded


def grille(s, code):
	return ''.join((c for (c, k) in zip(s[::-1], bin(code)[2:][::-1]) if k == '1'))[::-1]


def grille(message, code):
	return ''.join((c for (i, c) in enumerate(message) if 1 << len(message) - i - 1 & code))