...

/

Puzzles 48 to 50

Puzzles 48 to 50

Examine the basic set operations, simple unicode encryption, and the guess and check framework in Python.

Puzzle 48

What is the output of the following code?

Note: Enter the output you guessed. Then, press the Run button, and your new Elo will be calculated. Don’t forget to save your Elo rating.

Press + to interact
Elo
1000
#############################
## id 390
## Puzzle Elo 1755
## Correctly solved 60 %
#############################
words_list = ["bitcoin",
"cryptocurrency",
"wallet"]
crawled_text = '''
Research produced by the University of
Cambridge estimates that in 2017,
there are 2.9 to 5.8 million unique
users using a cryptocurrency wallet,
most of them using bitcoin.
'''
split_text = crawled_text.split()
res1 = True in map(lambda word:
word in split_text, words_list)
res2 = any(word in words_list for word in split_text)
print(res1 == res2)

Enter the input below

Basic set operations

After executing the code puzzle, both res1 and res2 store whether the variable crawled_text contains a word from the word_list. Let’s look at the explanation to achieve this both ways.

  • res1: The map function checks for each element word in the word_list whether the word is an element of the split crawled_text. The default split function divides the string along the whitespaces. The result is iterable with three booleans. There is one for each word in the list of words word_list. Finally, we check whether one of them is True.
  • res2: The any function checks whether there is an element in the iterable that is True. As soon as it finds a True value, this function returns
...