Some coders possess laser-like code understanding skills. They look at a piece of source code, and the meaning pops immediately into their great minds. If you present them with a new code snippet, they’ll tell you in a few seconds what it does.
Since I’ve started to train this skill of rapid code understanding in 2017, I’ve made rapid progress towards being able to understand source code quickly. I’ve then created the Finxter.com app with my friends Lukas and Zohaib. Since then, hundreds of thousands of students have trained their code understanding skills by solving Python code puzzles on the Finxter web app.
Many of them have surpassed our skills by a wide margin in being able to see through source code quickly.
How did they do it? And how can you do the same?
The answer is simple: you must burn the basic code patterns into your brain. If you look at a word, you don’t realize the characters anymore. The word is a single piece of information. If a chess master looks at a chess position, he doesn’t see a dozen chess pieces. The whole chess position is a single piece of information.
You can burn those code patterns into your head by solving hundreds of code puzzles that make use of similar patterns but produce different outputs. This article gives you 100 code puzzles so that you can learn this mastery skill, too.
Action steps:
- Go over each code puzzle and take 10 seconds or so per puzzle.
- Guess the output of the code puzzle.
- Check your output against your guess.
- Repeat over and over again.
Ready? So let’s start rewiring your brain cells!
(But I warn you, don’t stop solving the code puzzles just because it gets boring. The puzzles are designed to be similar so that you can understand conditional code snippets 10x faster in all your future code projects. Push through your impulse to quit until you can see the source code in a second or two.)
10 Code Puzzles With Two Variables
Let’s start slowly. Can you solve these 10 code puzzles in less than 10 minutes?
# Puzzle 0 a, b = False, True if not b and not a and a: if b: print('code') elif a and b: print('mastery') print('python') elif a: if a and b or not b and not a: print('python') print('python') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 0: [1] Create and initialize 2 variables: a, b = False, True. [2] Check condition (not b and not a and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b). If it evaluates to True, print code to the shell. Otherwise, check condition (a and b). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (a). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (a and b or not b and not a). If it evaluates to True, print python to the shell. Otherwise, print python. ''' # OUTPUT: ''' python ''' # Puzzle 1 a, b = True, True if b or a and not a: if a or b: print('finxter') elif b or a: print('finxter') print('42') elif a: if not b and b and a: print('code') print('42') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 1: [1] Create and initialize 2 variables: a, b = True, True. [2] Check condition (b or a and not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or b). If it evaluates to True, print finxter to the shell. Otherwise, check condition (b or a). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (a). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (not b and b and a). If it evaluates to True, print code to the shell. Otherwise, print 42. ''' # OUTPUT: ''' finxter 42 ''' # Puzzle 2 a, b = False, True if b: if not b or a or b or not a: print('finxter') elif b or not b or a: print('python') print('finxter') elif a and b: if b and a: print('mastery') print('learn') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 2: [1] Create and initialize 2 variables: a, b = False, True. [2] Check condition (b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or a or b or not a). If it evaluates to True, print finxter to the shell. Otherwise, check condition (b or not b or a). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (a and b). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (b and a). If it evaluates to True, print mastery to the shell. Otherwise, print learn. ''' # OUTPUT: ''' finxter finxter ''' # Puzzle 3 a, b = True, False if not a: if a and b and not b: print('code') elif a or b: print('42') print('finxter') elif a and not a: if b or not a and not b or a: print('learn') print('finxter') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 3: [1] Create and initialize 2 variables: a, b = True, False. [2] Check condition (not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and b and not b). If it evaluates to True, print code to the shell. Otherwise, check condition (a or b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (a and not a). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (b or not a and not b or a). If it evaluates to True, print learn to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' mastery ''' # Puzzle 4 a, b = True, False if not a: if not b or a and b or not a: print('python') elif not a and a and not b: print('finxter') print('learn') elif b or not a and not b: if b and not a and a or not b: print('finxter') print('finxter') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 4: [1] Create and initialize 2 variables: a, b = True, False. [2] Check condition (not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or a and b or not a). If it evaluates to True, print python to the shell. Otherwise, check condition (not a and a and not b). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (b or not a and not b). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (b and not a and a or not b). If it evaluates to True, print finxter to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' learn ''' # Puzzle 5 a, b = True, False if b or not a or not b: if not a: print('yes') elif a: print('finxter') print('42') elif b and not a and a: if not a or a and b: print('finxter') print('yes') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 5: [1] Create and initialize 2 variables: a, b = True, False. [2] Check condition (b or not a or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not a). If it evaluates to True, print yes to the shell. Otherwise, check condition (a). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (b and not a and a). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (not a or a and b). If it evaluates to True, print finxter to the shell. Otherwise, print yes. ''' # OUTPUT: ''' finxter 42 ''' # Puzzle 6 a, b = True, False if b or not b or not a and a: if not a and a or not b and b: print('love') elif a: print('yes') print('42') elif b: if b and not b and a and not a: print('yes') print('love') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 6: [1] Create and initialize 2 variables: a, b = True, False. [2] Check condition (b or not b or not a and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not a and a or not b and b). If it evaluates to True, print love to the shell. Otherwise, check condition (a). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (b). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (b and not b and a and not a). If it evaluates to True, print yes to the shell. Otherwise, print love. ''' # OUTPUT: ''' yes 42 ''' # Puzzle 7 a, b = True, False if not b: if not a and b and a and not b: print('yes') elif a: print('42') print('learn') elif a: if not b and a and b and not a: print('learn') print('finxter') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 7: [1] Create and initialize 2 variables: a, b = True, False. [2] Check condition (not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not a and b and a and not b). If it evaluates to True, print yes to the shell. Otherwise, check condition (a). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (a). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (not b and a and b and not a). If it evaluates to True, print learn to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' 42 learn ''' # Puzzle 8 a, b = False, False if a or not b: if a or b or not b: print('yes') elif b and not b: print('code') print('yes') elif a or b or not a: if b and not b and not a and a: print('yes') print('code') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 8: [1] Create and initialize 2 variables: a, b = False, False. [2] Check condition (a or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or b or not b). If it evaluates to True, print yes to the shell. Otherwise, check condition (b and not b). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (a or b or not a). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (b and not b and not a and a). If it evaluates to True, print yes to the shell. Otherwise, print code. ''' # OUTPUT: ''' yes yes ''' # Puzzle 9 a, b = False, False if b or not b or a: if a or b and not a: print('love') elif a or not b: print('python') print('python') elif b or not b: if b and not b or not a or a: print('learn') print('python') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 9: [1] Create and initialize 2 variables: a, b = False, False. [2] Check condition (b or not b or a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or b and not a). If it evaluates to True, print love to the shell. Otherwise, check condition (a or not b). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (b or not b). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (b and not b or not a or a). If it evaluates to True, print learn to the shell. Otherwise, print python. ''' # OUTPUT: ''' python python '''
30 Code Puzzles With Three Variables
You’re ready for the next level. Can you solve these 30 code puzzles in less than 10 minutes? (That’s 3x the speed on a more difficult code puzzle type.)
# Puzzle 0 a, b, c = False, False, True if c: if a and b or c and not b: print('finxter') elif not a: print('mastery') print('learn') elif a and b: if b and not c: print('python') print('love') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 0: [1] Create and initialize 3 variables: a, b, c = False, False, True. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and b or c and not b). If it evaluates to True, print finxter to the shell. Otherwise, check condition (not a). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (a and b). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (b and not c). If it evaluates to True, print python to the shell. Otherwise, print love. ''' # OUTPUT: ''' finxter learn ''' # Puzzle 1 a, b, c = False, True, True if not a or c: if a and b and c: print('finxter') elif not b or c: print('42') print('mastery') elif b and a or c: if not a and c and a or not b: print('finxter') print('python') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 1: [1] Create and initialize 3 variables: a, b, c = False, True, True. [2] Check condition (not a or c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and b and c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (not b or c). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (b and a or c). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (not a and c and a or not b). If it evaluates to True, print finxter to the shell. Otherwise, print python. ''' # OUTPUT: ''' 42 mastery ''' # Puzzle 2 a, b, c = True, True, False if not a or not c or a: if b or c: print('learn') elif c and b or a: print('love') print('42') elif c or b and not a: if not a: print('finxter') print('love') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 2: [1] Create and initialize 3 variables: a, b, c = True, True, False. [2] Check condition (not a or not c or a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c). If it evaluates to True, print learn to the shell. Otherwise, check condition (c and b or a). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (c or b and not a). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not a). If it evaluates to True, print finxter to the shell. Otherwise, print love. ''' # OUTPUT: ''' learn 42 ''' # Puzzle 3 a, b, c = False, True, False if c: if a: print('finxter') elif not a or b: print('learn') print('finxter') elif not b and b: if b or c: print('learn') print('code') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 3: [1] Create and initialize 3 variables: a, b, c = False, True, False. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print finxter to the shell. Otherwise, check condition (not a or b). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (not b and b). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (b or c). If it evaluates to True, print learn to the shell. Otherwise, print code. ''' # OUTPUT: ''' yes ''' # Puzzle 4 a, b, c = True, False, True if not c or a or not b: if b or c: print('python') elif b: print('love') print('42') elif c and b and not c: if a or c: print('mastery') print('yes') else: print('finxter') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 4: [1] Create and initialize 3 variables: a, b, c = True, False, True. [2] Check condition (not c or a or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c). If it evaluates to True, print python to the shell. Otherwise, check condition (b). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (c and b and not c). If it evaluates to True, move on to the next step [6]. Otherwise, print finxter to the shell. [6] Check condition (a or c). If it evaluates to True, print mastery to the shell. Otherwise, print yes. ''' # OUTPUT: ''' python 42 ''' # Puzzle 5 a, b, c = False, True, True if c or not b or b: if c and b: print('love') elif not a or a: print('yes') print('yes') elif a or b or not c: if not c or a and not a: print('42') print('yes') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 5: [1] Create and initialize 3 variables: a, b, c = False, True, True. [2] Check condition (c or not b or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c and b). If it evaluates to True, print love to the shell. Otherwise, check condition (not a or a). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (a or b or not c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (not c or a and not a). If it evaluates to True, print 42 to the shell. Otherwise, print yes. ''' # OUTPUT: ''' love yes ''' # Puzzle 6 a, b, c = False, False, False if a or b or not b: if a or b or c or not c: print('python') elif b: print('42') print('love') elif b or a: if a and b and c: print('love') print('mastery') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 6: [1] Create and initialize 3 variables: a, b, c = False, False, False. [2] Check condition (a or b or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or b or c or not c). If it evaluates to True, print python to the shell. Otherwise, check condition (b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (b or a). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (a and b and c). If it evaluates to True, print love to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' python love ''' # Puzzle 7 a, b, c = False, True, True if b or a or not c or not b: if b or c and not b: print('love') elif a or b and not c: print('learn') print('learn') elif b: if not b and b and a: print('mastery') print('python') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 7: [1] Create and initialize 3 variables: a, b, c = False, True, True. [2] Check condition (b or a or not c or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c and not b). If it evaluates to True, print love to the shell. Otherwise, check condition (a or b and not c). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (b). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not b and b and a). If it evaluates to True, print mastery to the shell. Otherwise, print python. ''' # OUTPUT: ''' love learn ''' # Puzzle 8 a, b, c = False, False, True if c and not c: if c or not c: print('learn') elif not a or b or not c: print('python') print('python') elif a: if c or not b: print('yes') print('finxter') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 8: [1] Create and initialize 3 variables: a, b, c = False, False, True. [2] Check condition (c and not c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c or not c). If it evaluates to True, print learn to the shell. Otherwise, check condition (not a or b or not c). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (a). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (c or not b). If it evaluates to True, print yes to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' 42 ''' # Puzzle 9 a, b, c = True, False, True if c: if not b or b and not c: print('finxter') elif c and not b: print('python') print('code') elif not b or b and c: if not a and a: print('mastery') print('python') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 9: [1] Create and initialize 3 variables: a, b, c = True, False, True. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or b and not c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (c and not b). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (not b or b and c). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (not a and a). If it evaluates to True, print mastery to the shell. Otherwise, print python. ''' # OUTPUT: ''' finxter code ''' # Puzzle 10 a, b, c = True, False, False if not b and c: if a or not c or b: print('learn') elif a: print('yes') print('love') elif not b or c or not c: if c and not a and b: print('finxter') print('learn') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 10: [1] Create and initialize 3 variables: a, b, c = True, False, False. [2] Check condition (not b and c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or not c or b). If it evaluates to True, print learn to the shell. Otherwise, check condition (a). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (not b or c or not c). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (c and not a and b). If it evaluates to True, print finxter to the shell. Otherwise, print learn. ''' # OUTPUT: ''' learn ''' # Puzzle 11 a, b, c = False, False, True if c and not c and b: if not a and b: print('code') elif not a or a and not b: print('42') print('yes') elif b: if not b and b or a: print('yes') print('learn') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 11: [1] Create and initialize 3 variables: a, b, c = False, False, True. [2] Check condition (c and not c and b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not a and b). If it evaluates to True, print code to the shell. Otherwise, check condition (not a or a and not b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (b). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (not b and b or a). If it evaluates to True, print yes to the shell. Otherwise, print learn. ''' # OUTPUT: ''' python ''' # Puzzle 12 a, b, c = False, False, True if a and c or b: if b and c: print('mastery') elif b: print('python') print('love') elif c or a and not c: if b and c and not c and a: print('yes') print('42') else: print('finxter') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 12: [1] Create and initialize 3 variables: a, b, c = False, False, True. [2] Check condition (a and c or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and c). If it evaluates to True, print mastery to the shell. Otherwise, check condition (b). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (c or a and not c). If it evaluates to True, move on to the next step [6]. Otherwise, print finxter to the shell. [6] Check condition (b and c and not c and a). If it evaluates to True, print yes to the shell. Otherwise, print 42. ''' # OUTPUT: ''' 42 ''' # Puzzle 13 a, b, c = False, True, True if b: if a and b and c or not c: print('learn') elif not c and a and c: print('42') print('mastery') elif b or c and a: if c or b and not b: print('finxter') print('learn') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 13: [1] Create and initialize 3 variables: a, b, c = False, True, True. [2] Check condition (b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and b and c or not c). If it evaluates to True, print learn to the shell. Otherwise, check condition (not c and a and c). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (b or c and a). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (c or b and not b). If it evaluates to True, print finxter to the shell. Otherwise, print learn. ''' # OUTPUT: ''' mastery ''' # Puzzle 14 a, b, c = True, True, True if a and c and not a and b: if not c and a or not a: print('42') elif b: print('python') print('mastery') elif b and c or not b: if c or not a or a and b: print('love') print('learn') else: print('finxter') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 14: [1] Create and initialize 3 variables: a, b, c = True, True, True. [2] Check condition (a and c and not a and b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c and a or not a). If it evaluates to True, print 42 to the shell. Otherwise, check condition (b). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (b and c or not b). If it evaluates to True, move on to the next step [6]. Otherwise, print finxter to the shell. [6] Check condition (c or not a or a and b). If it evaluates to True, print love to the shell. Otherwise, print learn. ''' # OUTPUT: ''' love learn ''' # Puzzle 15 a, b, c = True, True, False if a and c and b and not c: if c: print('finxter') elif b or c and a: print('learn') print('code') elif not c: if not c and b and a: print('learn') print('yes') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 15: [1] Create and initialize 3 variables: a, b, c = True, True, False. [2] Check condition (a and c and b and not c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (b or c and a). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (not c). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not c and b and a). If it evaluates to True, print learn to the shell. Otherwise, print yes. ''' # OUTPUT: ''' learn yes ''' # Puzzle 16 a, b, c = True, False, True if c or not b: if b or c and a and not b: print('learn') elif c or a or b: print('42') print('code') elif c: if a: print('yes') print('love') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 16: [1] Create and initialize 3 variables: a, b, c = True, False, True. [2] Check condition (c or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c and a and not b). If it evaluates to True, print learn to the shell. Otherwise, check condition (c or a or b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (a). If it evaluates to True, print yes to the shell. Otherwise, print love. ''' # OUTPUT: ''' learn code ''' # Puzzle 17 a, b, c = True, False, False if a: if b and c or not c or a: print('code') elif a or not b or not c: print('love') print('learn') elif a or c: if not b: print('finxter') print('love') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 17: [1] Create and initialize 3 variables: a, b, c = True, False, False. [2] Check condition (a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and c or not c or a). If it evaluates to True, print code to the shell. Otherwise, check condition (a or not b or not c). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (a or c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (not b). If it evaluates to True, print finxter to the shell. Otherwise, print love. ''' # OUTPUT: ''' code learn ''' # Puzzle 18 a, b, c = False, True, True if a and b and not b and c: if b or c: print('code') elif c and not b and b: print('42') print('code') elif c or not c: if a or not b or b and not a: print('mastery') print('42') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 18: [1] Create and initialize 3 variables: a, b, c = False, True, True. [2] Check condition (a and b and not b and c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c). If it evaluates to True, print code to the shell. Otherwise, check condition (c and not b and b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (c or not c). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (a or not b or b and not a). If it evaluates to True, print mastery to the shell. Otherwise, print 42. ''' # OUTPUT: ''' mastery 42 ''' # Puzzle 19 a, b, c = False, False, False if b and not c: if c or b or not c or a: print('love') elif c and a: print('love') print('code') elif not b: if b or c: print('code') print('learn') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 19: [1] Create and initialize 3 variables: a, b, c = False, False, False. [2] Check condition (b and not c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c or b or not c or a). If it evaluates to True, print love to the shell. Otherwise, check condition (c and a). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (not b). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (b or c). If it evaluates to True, print code to the shell. Otherwise, print learn. ''' # OUTPUT: ''' learn ''' # Puzzle 20 a, b, c = True, False, False if c or a and b or not a: if a and b and c: print('finxter') elif not a: print('code') print('42') elif c and a or b: if a or not c or c or not a: print('learn') print('mastery') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 20: [1] Create and initialize 3 variables: a, b, c = True, False, False. [2] Check condition (c or a and b or not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and b and c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (not a). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (c and a or b). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (a or not c or c or not a). If it evaluates to True, print learn to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' 42 ''' # Puzzle 21 a, b, c = False, True, False if a: if c or a and b: print('code') elif b or not c: print('python') print('love') elif c and a: if c or b or a and not a: print('code') print('42') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 21: [1] Create and initialize 3 variables: a, b, c = False, True, False. [2] Check condition (a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c or a and b). If it evaluates to True, print code to the shell. Otherwise, check condition (b or not c). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (c and a). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (c or b or a and not a). If it evaluates to True, print code to the shell. Otherwise, print 42. ''' # OUTPUT: ''' python ''' # Puzzle 22 a, b, c = True, False, True if a: if a or b: print('love') elif not c and b: print('yes') print('yes') elif not b and not a or c: if not a and b: print('love') print('code') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 22: [1] Create and initialize 3 variables: a, b, c = True, False, True. [2] Check condition (a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or b). If it evaluates to True, print love to the shell. Otherwise, check condition (not c and b). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (not b and not a or c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (not a and b). If it evaluates to True, print love to the shell. Otherwise, print code. ''' # OUTPUT: ''' love yes ''' # Puzzle 23 a, b, c = False, True, False if b and a: if a: print('code') elif c and b: print('learn') print('42') elif c: if b and a or not a: print('python') print('love') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 23: [1] Create and initialize 3 variables: a, b, c = False, True, False. [2] Check condition (b and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print code to the shell. Otherwise, check condition (c and b). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (b and a or not a). If it evaluates to True, print python to the shell. Otherwise, print love. ''' # OUTPUT: ''' mastery ''' # Puzzle 24 a, b, c = False, False, False if not a: if a and not b and c: print('learn') elif b or c: print('love') print('love') elif a or not b or b: if not b and c: print('mastery') print('42') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 24: [1] Create and initialize 3 variables: a, b, c = False, False, False. [2] Check condition (not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and not b and c). If it evaluates to True, print learn to the shell. Otherwise, check condition (b or c). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (a or not b or b). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (not b and c). If it evaluates to True, print mastery to the shell. Otherwise, print 42. ''' # OUTPUT: ''' love ''' # Puzzle 25 a, b, c = True, True, False if not a: if a or b: print('code') elif a and c: print('yes') print('yes') elif b: if not c or b or a and c: print('love') print('learn') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 25: [1] Create and initialize 3 variables: a, b, c = True, True, False. [2] Check condition (not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or b). If it evaluates to True, print code to the shell. Otherwise, check condition (a and c). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (b). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (not c or b or a and c). If it evaluates to True, print love to the shell. Otherwise, print learn. ''' # OUTPUT: ''' love learn ''' # Puzzle 26 a, b, c = True, False, False if not a: if b or c and not c: print('love') elif a and b or c: print('love') print('42') elif not b and c: if a: print('code') print('finxter') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 26: [1] Create and initialize 3 variables: a, b, c = True, False, False. [2] Check condition (not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c and not c). If it evaluates to True, print love to the shell. Otherwise, check condition (a and b or c). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (not b and c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (a). If it evaluates to True, print code to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' mastery ''' # Puzzle 27 a, b, c = False, True, False if not b and not a and b and a: if a or c or b or not c: print('learn') elif b or not b or c: print('mastery') print('learn') elif a and b: if a: print('finxter') print('learn') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 27: [1] Create and initialize 3 variables: a, b, c = False, True, False. [2] Check condition (not b and not a and b and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or c or b or not c). If it evaluates to True, print learn to the shell. Otherwise, check condition (b or not b or c). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (a and b). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (a). If it evaluates to True, print finxter to the shell. Otherwise, print learn. ''' # OUTPUT: ''' learn ''' # Puzzle 28 a, b, c = False, True, False if not c and a and b or not a: if not b or a or not c: print('mastery') elif not b or c and b: print('code') print('42') elif b: if c or not c and not a: print('love') print('yes') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 28: [1] Create and initialize 3 variables: a, b, c = False, True, False. [2] Check condition (not c and a and b or not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or a or not c). If it evaluates to True, print mastery to the shell. Otherwise, check condition (not b or c and b). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (b). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (c or not c and not a). If it evaluates to True, print love to the shell. Otherwise, print yes. ''' # OUTPUT: ''' mastery 42 ''' # Puzzle 29 a, b, c = True, False, False if a: if c or a: print('42') elif a: print('code') print('code') elif c and not a and b: if b or a: print('python') print('learn') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 29: [1] Create and initialize 3 variables: a, b, c = True, False, False. [2] Check condition (a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c or a). If it evaluates to True, print 42 to the shell. Otherwise, check condition (a). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (c and not a and b). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (b or a). If it evaluates to True, print python to the shell. Otherwise, print learn. ''' # OUTPUT: ''' 42 code '''
30 Code Puzzles with Four Variables
Wow, this was harder, wasn’t it? But now you’re ready to solve these 30 code puzzles in less than 10 minutes, aren’t you? (Same speed as before but higher complexity.)
# Puzzle 0 a, b, c, d = False, False, False, True if d and c and not d and b: if d or not a: print('learn') elif c: print('yes') print('python') elif not a or d: if not a: print('finxter') print('python') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 0: [1] Create and initialize 4 variables: a, b, c, d = False, False, False, True. [2] Check condition (d and c and not d and b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d or not a). If it evaluates to True, print learn to the shell. Otherwise, check condition (c). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (not a or d). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (not a). If it evaluates to True, print finxter to the shell. Otherwise, print python. ''' # OUTPUT: ''' finxter python ''' # Puzzle 1 a, b, c, d = True, True, True, True if not c: if not b or c: print('yes') elif b or not d or a: print('finxter') print('mastery') elif not d: if d or b: print('finxter') print('mastery') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 1: [1] Create and initialize 4 variables: a, b, c, d = True, True, True, True. [2] Check condition (not c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or c). If it evaluates to True, print yes to the shell. Otherwise, check condition (b or not d or a). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (not d). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (d or b). If it evaluates to True, print finxter to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' 42 ''' # Puzzle 2 a, b, c, d = True, True, False, True if a: if not d and not a and d or not c: print('finxter') elif not b or a and b: print('finxter') print('learn') elif c and not d: if b or not b and not a or a: print('learn') print('love') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 2: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, True. [2] Check condition (a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not d and not a and d or not c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (not b or a and b). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (c and not d). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (b or not b and not a or a). If it evaluates to True, print learn to the shell. Otherwise, print love. ''' # OUTPUT: ''' finxter learn ''' # Puzzle 3 a, b, c, d = False, False, False, False if a and d and not b and c: if a: print('yes') elif d and a: print('love') print('learn') elif a and c or b: if d or b or not b: print('yes') print('finxter') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 3: [1] Create and initialize 4 variables: a, b, c, d = False, False, False, False. [2] Check condition (a and d and not b and c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print yes to the shell. Otherwise, check condition (d and a). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (a and c or b). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (d or b or not b). If it evaluates to True, print yes to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' python ''' # Puzzle 4 a, b, c, d = True, False, True, False if not d or d: if not d and not b or b or d: print('code') elif c or d: print('python') print('learn') elif b and c: if a or d or b and c: print('finxter') print('python') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 4: [1] Create and initialize 4 variables: a, b, c, d = True, False, True, False. [2] Check condition (not d or d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not d and not b or b or d). If it evaluates to True, print code to the shell. Otherwise, check condition (c or d). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (b and c). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (a or d or b and c). If it evaluates to True, print finxter to the shell. Otherwise, print python. ''' # OUTPUT: ''' code learn ''' # Puzzle 5 a, b, c, d = False, False, False, False if not d or d or a or b: if b: print('yes') elif a and not b: print('42') print('love') elif c and not b: if b and not d and not b: print('yes') print('yes') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 5: [1] Create and initialize 4 variables: a, b, c, d = False, False, False, False. [2] Check condition (not d or d or a or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b). If it evaluates to True, print yes to the shell. Otherwise, check condition (a and not b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (c and not b). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (b and not d and not b). If it evaluates to True, print yes to the shell. Otherwise, print yes. ''' # OUTPUT: ''' love ''' # Puzzle 6 a, b, c, d = True, False, True, False if c or not a: if b and d: print('python') elif a or d and c: print('love') print('yes') elif c: if not d and b or c: print('love') print('code') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 6: [1] Create and initialize 4 variables: a, b, c, d = True, False, True, False. [2] Check condition (c or not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and d). If it evaluates to True, print python to the shell. Otherwise, check condition (a or d and c). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (not d and b or c). If it evaluates to True, print love to the shell. Otherwise, print code. ''' # OUTPUT: ''' love yes ''' # Puzzle 7 a, b, c, d = False, True, False, True if not c or b and a and c: if c or not c or b and a: print('42') elif d and not d: print('code') print('mastery') elif c or not c and a: if b: print('42') print('code') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 7: [1] Create and initialize 4 variables: a, b, c, d = False, True, False, True. [2] Check condition (not c or b and a and c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c or not c or b and a). If it evaluates to True, print 42 to the shell. Otherwise, check condition (d and not d). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (c or not c and a). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (b). If it evaluates to True, print 42 to the shell. Otherwise, print code. ''' # OUTPUT: ''' 42 mastery ''' # Puzzle 8 a, b, c, d = True, True, False, True if a or c and d or not a: if not d: print('learn') elif c or d: print('learn') print('love') elif a: if d: print('yes') print('42') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 8: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, True. [2] Check condition (a or c and d or not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not d). If it evaluates to True, print learn to the shell. Otherwise, check condition (c or d). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (a). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (d). If it evaluates to True, print yes to the shell. Otherwise, print 42. ''' # OUTPUT: ''' learn love ''' # Puzzle 9 a, b, c, d = False, False, False, True if c: if not c and b: print('python') elif a: print('mastery') print('mastery') elif c or a: if c: print('finxter') print('code') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 9: [1] Create and initialize 4 variables: a, b, c, d = False, False, False, True. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c and b). If it evaluates to True, print python to the shell. Otherwise, check condition (a). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (c or a). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (c). If it evaluates to True, print finxter to the shell. Otherwise, print code. ''' # OUTPUT: ''' love ''' # Puzzle 10 a, b, c, d = False, False, True, True if not c and b and d: if not c: print('mastery') elif not b or not a or c: print('learn') print('learn') elif c or b and d: if a or c or b and d: print('finxter') print('python') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 10: [1] Create and initialize 4 variables: a, b, c, d = False, False, True, True. [2] Check condition (not c and b and d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c). If it evaluates to True, print mastery to the shell. Otherwise, check condition (not b or not a or c). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (c or b and d). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (a or c or b and d). If it evaluates to True, print finxter to the shell. Otherwise, print python. ''' # OUTPUT: ''' finxter python ''' # Puzzle 11 a, b, c, d = False, False, True, False if b or a: if b: print('finxter') elif a or d or not c: print('finxter') print('42') elif not b: if a and c or b: print('code') print('code') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 11: [1] Create and initialize 4 variables: a, b, c, d = False, False, True, False. [2] Check condition (b or a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b). If it evaluates to True, print finxter to the shell. Otherwise, check condition (a or d or not c). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (not b). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (a and c or b). If it evaluates to True, print code to the shell. Otherwise, print code. ''' # OUTPUT: ''' code ''' # Puzzle 12 a, b, c, d = True, True, False, True if c: if b and d: print('42') elif c or d or a: print('42') print('42') elif d or b or not d: if c: print('finxter') print('python') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 12: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, True. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and d). If it evaluates to True, print 42 to the shell. Otherwise, check condition (c or d or a). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (d or b or not d). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (c). If it evaluates to True, print finxter to the shell. Otherwise, print python. ''' # OUTPUT: ''' python ''' # Puzzle 13 a, b, c, d = False, True, False, False if a and b or not d and not b: if d and b and not c or a: print('finxter') elif a or not c: print('code') print('yes') elif c: if not b: print('finxter') print('python') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 13: [1] Create and initialize 4 variables: a, b, c, d = False, True, False, False. [2] Check condition (a and b or not d and not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d and b and not c or a). If it evaluates to True, print finxter to the shell. Otherwise, check condition (a or not c). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (not b). If it evaluates to True, print finxter to the shell. Otherwise, print python. ''' # OUTPUT: ''' mastery ''' # Puzzle 14 a, b, c, d = True, True, True, True if d or not b or b: if not c or c and not d: print('love') elif not d and b or a: print('mastery') print('mastery') elif not c or a: if d and b and c and not d: print('code') print('mastery') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 14: [1] Create and initialize 4 variables: a, b, c, d = True, True, True, True. [2] Check condition (d or not b or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c or c and not d). If it evaluates to True, print love to the shell. Otherwise, check condition (not d and b or a). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (not c or a). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (d and b and c and not d). If it evaluates to True, print code to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' mastery mastery ''' # Puzzle 15 a, b, c, d = True, True, True, False if d and not c: if d and c and not d or b: print('code') elif not b or not c or a: print('code') print('learn') elif not c: if a and c and b or not d: print('python') print('python') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 15: [1] Create and initialize 4 variables: a, b, c, d = True, True, True, False. [2] Check condition (d and not c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d and c and not d or b). If it evaluates to True, print code to the shell. Otherwise, check condition (not b or not c or a). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (not c). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (a and c and b or not d). If it evaluates to True, print python to the shell. Otherwise, print python. ''' # OUTPUT: ''' mastery ''' # Puzzle 16 a, b, c, d = True, False, False, True if c: if b and c or not c or not d: print('mastery') elif c or d or not b: print('code') print('python') elif b or d and not c: if c or b or a: print('finxter') print('code') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 16: [1] Create and initialize 4 variables: a, b, c, d = True, False, False, True. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and c or not c or not d). If it evaluates to True, print mastery to the shell. Otherwise, check condition (c or d or not b). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (b or d and not c). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (c or b or a). If it evaluates to True, print finxter to the shell. Otherwise, print code. ''' # OUTPUT: ''' finxter code ''' # Puzzle 17 a, b, c, d = False, False, True, False if c and a: if c: print('love') elif d or a: print('code') print('finxter') elif a or c and not c: if d: print('mastery') print('mastery') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 17: [1] Create and initialize 4 variables: a, b, c, d = False, False, True, False. [2] Check condition (c and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c). If it evaluates to True, print love to the shell. Otherwise, check condition (d or a). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (a or c and not c). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (d). If it evaluates to True, print mastery to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' love ''' # Puzzle 18 a, b, c, d = True, True, False, False if d or b: if not d or c: print('42') elif not a and d: print('code') print('finxter') elif not b: if d and c: print('code') print('love') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 18: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, False. [2] Check condition (d or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not d or c). If it evaluates to True, print 42 to the shell. Otherwise, check condition (not a and d). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (not b). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (d and c). If it evaluates to True, print code to the shell. Otherwise, print love. ''' # OUTPUT: ''' 42 finxter ''' # Puzzle 19 a, b, c, d = True, False, False, False if b and d and not d or not b: if not b or c: print('code') elif d or c: print('yes') print('love') elif d: if c and a: print('42') print('love') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 19: [1] Create and initialize 4 variables: a, b, c, d = True, False, False, False. [2] Check condition (b and d and not d or not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or c). If it evaluates to True, print code to the shell. Otherwise, check condition (d or c). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (d). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (c and a). If it evaluates to True, print 42 to the shell. Otherwise, print love. ''' # OUTPUT: ''' code love ''' # Puzzle 20 a, b, c, d = True, True, False, False if not a or d or a or c: if c: print('42') elif d or c and not c: print('mastery') print('code') elif d or not b or b: if a: print('mastery') print('python') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 20: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, False. [2] Check condition (not a or d or a or c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c). If it evaluates to True, print 42 to the shell. Otherwise, check condition (d or c and not c). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (d or not b or b). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (a). If it evaluates to True, print mastery to the shell. Otherwise, print python. ''' # OUTPUT: ''' code ''' # Puzzle 21 a, b, c, d = False, True, False, False if d and a and b: if a: print('finxter') elif b and not b: print('yes') print('learn') elif not c and d or c: if a: print('yes') print('code') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 21: [1] Create and initialize 4 variables: a, b, c, d = False, True, False, False. [2] Check condition (d and a and b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print finxter to the shell. Otherwise, check condition (b and not b). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (not c and d or c). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (a). If it evaluates to True, print yes to the shell. Otherwise, print code. ''' # OUTPUT: ''' love ''' # Puzzle 22 a, b, c, d = True, False, True, False if not b and a and d or b: if d: print('42') elif not a or c: print('mastery') print('finxter') elif b or d: if a or c or not d and d: print('code') print('42') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 22: [1] Create and initialize 4 variables: a, b, c, d = True, False, True, False. [2] Check condition (not b and a and d or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d). If it evaluates to True, print 42 to the shell. Otherwise, check condition (not a or c). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (b or d). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (a or c or not d and d). If it evaluates to True, print code to the shell. Otherwise, print 42. ''' # OUTPUT: ''' mastery ''' # Puzzle 23 a, b, c, d = False, True, False, False if not a: if b and d or a: print('yes') elif c and not c: print('love') print('mastery') elif b or d: if not a and b or not d: print('yes') print('learn') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 23: [1] Create and initialize 4 variables: a, b, c, d = False, True, False, False. [2] Check condition (not a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and d or a). If it evaluates to True, print yes to the shell. Otherwise, check condition (c and not c). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (b or d). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (not a and b or not d). If it evaluates to True, print yes to the shell. Otherwise, print learn. ''' # OUTPUT: ''' mastery ''' # Puzzle 24 a, b, c, d = True, True, False, True if a or not a or d or c: if b: print('42') elif d or a: print('love') print('42') elif b and a: if b and a or d and not c: print('42') print('yes') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 24: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, True. [2] Check condition (a or not a or d or c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b). If it evaluates to True, print 42 to the shell. Otherwise, check condition (d or a). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (b and a). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (b and a or d and not c). If it evaluates to True, print 42 to the shell. Otherwise, print yes. ''' # OUTPUT: ''' 42 42 ''' # Puzzle 25 a, b, c, d = True, True, True, False if a: if not a and a or b: print('42') elif a and d and c: print('python') print('learn') elif d and not c: if not b: print('mastery') print('code') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 25: [1] Create and initialize 4 variables: a, b, c, d = True, True, True, False. [2] Check condition (a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not a and a or b). If it evaluates to True, print 42 to the shell. Otherwise, check condition (a and d and c). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (d and not c). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (not b). If it evaluates to True, print mastery to the shell. Otherwise, print code. ''' # OUTPUT: ''' 42 learn ''' # Puzzle 26 a, b, c, d = True, False, False, False if c: if d and not a and not b or not d: print('mastery') elif d: print('finxter') print('learn') elif not a: if a and not b and d: print('python') print('love') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 26: [1] Create and initialize 4 variables: a, b, c, d = True, False, False, False. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d and not a and not b or not d). If it evaluates to True, print mastery to the shell. Otherwise, check condition (d). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (not a). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (a and not b and d). If it evaluates to True, print python to the shell. Otherwise, print love. ''' # OUTPUT: ''' code ''' # Puzzle 27 a, b, c, d = True, True, False, False if b and not a or d: if not a and c and d: print('42') elif c: print('yes') print('python') elif not b and c: if not d and b or not a and c: print('love') print('learn') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 27: [1] Create and initialize 4 variables: a, b, c, d = True, True, False, False. [2] Check condition (b and not a or d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not a and c and d). If it evaluates to True, print 42 to the shell. Otherwise, check condition (c). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (not b and c). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (not d and b or not a and c). If it evaluates to True, print love to the shell. Otherwise, print learn. ''' # OUTPUT: ''' python ''' # Puzzle 28 a, b, c, d = False, False, True, False if d or a and not a and not b: if d or not b: print('python') elif d and c and b: print('finxter') print('python') elif a and b: if b and not b or c or d: print('42') print('yes') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 28: [1] Create and initialize 4 variables: a, b, c, d = False, False, True, False. [2] Check condition (d or a and not a and not b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d or not b). If it evaluates to True, print python to the shell. Otherwise, check condition (d and c and b). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (a and b). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (b and not b or c or d). If it evaluates to True, print 42 to the shell. Otherwise, print yes. ''' # OUTPUT: ''' love ''' # Puzzle 29 a, b, c, d = False, True, True, False if a and not b and d: if a and not a: print('love') elif c and not b: print('code') print('python') elif c and a: if not c: print('42') print('finxter') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 29: [1] Create and initialize 4 variables: a, b, c, d = False, True, True, False. [2] Check condition (a and not b and d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and not a). If it evaluates to True, print love to the shell. Otherwise, check condition (c and not b). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (c and a). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (not c). If it evaluates to True, print 42 to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' learn '''
30 Code Puzzles with Five Variables
To be frank, I didn’t expect you make it that far. Are you ready for the final 30 code puzzles in 10 minutes? (Same speed as before but higher complexity.)
# Puzzle 0 a, b, c, d, e = False, True, False, False, True if e: if not c or e and not d or not e: print('mastery') elif d and a and c: print('learn') print('mastery') elif d and not d or a: if b or c or a: print('learn') print('finxter') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 0: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, False, False, True. [2] Check condition (e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c or e and not d or not e). If it evaluates to True, print mastery to the shell. Otherwise, check condition (d and a and c). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (d and not d or a). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (b or c or a). If it evaluates to True, print learn to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' mastery mastery ''' # Puzzle 1 a, b, c, d, e = True, False, False, False, False if a and b: if b or d and not b: print('yes') elif c: print('42') print('42') elif b or a: if not c or c and not e or a: print('42') print('code') else: print('finxter') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 1: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, False, False, False. [2] Check condition (a and b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or d and not b). If it evaluates to True, print yes to the shell. Otherwise, check condition (c). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (b or a). If it evaluates to True, move on to the next step [6]. Otherwise, print finxter to the shell. [6] Check condition (not c or c and not e or a). If it evaluates to True, print 42 to the shell. Otherwise, print code. ''' # OUTPUT: ''' 42 code ''' # Puzzle 2 a, b, c, d, e = True, True, False, True, True if not a or d and e and not e: if c and e and not b: print('learn') elif e or b or d: print('42') print('yes') elif not d and c: if b: print('yes') print('mastery') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 2: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, False, True, True. [2] Check condition (not a or d and e and not e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c and e and not b). If it evaluates to True, print learn to the shell. Otherwise, check condition (e or b or d). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (not d and c). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (b). If it evaluates to True, print yes to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' 42 ''' # Puzzle 3 a, b, c, d, e = False, True, True, True, False if d and c or a or b: if d and e: print('learn') elif a or e: print('finxter') print('yes') elif d: if e and b: print('python') print('42') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 3: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, True, True, False. [2] Check condition (d and c or a or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d and e). If it evaluates to True, print learn to the shell. Otherwise, check condition (a or e). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (d). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (e and b). If it evaluates to True, print python to the shell. Otherwise, print 42. ''' # OUTPUT: ''' yes ''' # Puzzle 4 a, b, c, d, e = True, False, False, True, False if b or not b or not c: if e and b and not b and d: print('42') elif not b or b and not c: print('python') print('python') elif d and e: if a: print('mastery') print('love') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 4: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, False, True, False. [2] Check condition (b or not b or not c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (e and b and not b and d). If it evaluates to True, print 42 to the shell. Otherwise, check condition (not b or b and not c). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (d and e). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (a). If it evaluates to True, print mastery to the shell. Otherwise, print love. ''' # OUTPUT: ''' python python ''' # Puzzle 5 a, b, c, d, e = True, False, True, True, False if c: if a: print('learn') elif not e: print('code') print('love') elif a or e: if e: print('42') print('code') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 5: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, True, True, False. [2] Check condition (c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print learn to the shell. Otherwise, check condition (not e). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (a or e). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (e). If it evaluates to True, print 42 to the shell. Otherwise, print code. ''' # OUTPUT: ''' learn love ''' # Puzzle 6 a, b, c, d, e = False, False, False, True, False if not e: if e and d and b or c: print('code') elif c or not a and a: print('42') print('code') elif c or b: if c: print('yes') print('code') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 6: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, False, True, False. [2] Check condition (not e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (e and d and b or c). If it evaluates to True, print code to the shell. Otherwise, check condition (c or not a and a). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (c or b). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (c). If it evaluates to True, print yes to the shell. Otherwise, print code. ''' # OUTPUT: ''' code ''' # Puzzle 7 a, b, c, d, e = True, False, False, False, False if b and not b and not c and not e: if b or not d or c: print('mastery') elif a and b and e: print('mastery') print('yes') elif not a and not e or e: if c or a or not d or not a: print('42') print('python') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 7: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, False, False, False. [2] Check condition (b and not b and not c and not e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or not d or c). If it evaluates to True, print mastery to the shell. Otherwise, check condition (a and b and e). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print yes to the shell. [5] Check the elif condition (not a and not e or e). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (c or a or not d or not a). If it evaluates to True, print 42 to the shell. Otherwise, print python. ''' # OUTPUT: ''' yes ''' # Puzzle 8 a, b, c, d, e = True, True, False, True, False if not c or a or not b and d: if not b or not e or d and not a: print('yes') elif a or e: print('mastery') print('love') elif not b and c: if a and d or e and c: print('finxter') print('yes') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 8: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, False, True, False. [2] Check condition (not c or a or not b and d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or not e or d and not a). If it evaluates to True, print yes to the shell. Otherwise, check condition (a or e). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (not b and c). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (a and d or e and c). If it evaluates to True, print finxter to the shell. Otherwise, print yes. ''' # OUTPUT: ''' yes love ''' # Puzzle 9 a, b, c, d, e = False, True, True, True, False if not b and b and a: if a: print('mastery') elif e or a: print('code') print('learn') elif e and b or c: if b and c: print('mastery') print('learn') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 9: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, True, True, False. [2] Check condition (not b and b and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print mastery to the shell. Otherwise, check condition (e or a). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (e and b or c). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (b and c). If it evaluates to True, print mastery to the shell. Otherwise, print learn. ''' # OUTPUT: ''' mastery learn ''' # Puzzle 10 a, b, c, d, e = False, True, False, True, False if not e and b and d: if not c: print('finxter') elif not e: print('python') print('love') elif e: if a or not a: print('python') print('finxter') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 10: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, False, True, False. [2] Check condition (not e and b and d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (not e). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (e). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (a or not a). If it evaluates to True, print python to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' finxter love ''' # Puzzle 11 a, b, c, d, e = True, False, True, False, True if e: if not c or not a or b: print('mastery') elif c or d: print('finxter') print('python') elif c: if not b or a: print('learn') print('code') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 11: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, True, False, True. [2] Check condition (e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c or not a or b). If it evaluates to True, print mastery to the shell. Otherwise, check condition (c or d). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (not b or a). If it evaluates to True, print learn to the shell. Otherwise, print code. ''' # OUTPUT: ''' finxter python ''' # Puzzle 12 a, b, c, d, e = False, False, False, True, True if b and d: if not e: print('yes') elif b or c or not a: print('code') print('love') elif not a: if not e and not b and d and a: print('python') print('code') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 12: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, False, True, True. [2] Check condition (b and d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not e). If it evaluates to True, print yes to the shell. Otherwise, check condition (b or c or not a). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (not a). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not e and not b and d and a). If it evaluates to True, print python to the shell. Otherwise, print code. ''' # OUTPUT: ''' code ''' # Puzzle 13 a, b, c, d, e = False, True, True, False, True if d: if b or c and e: print('finxter') elif d or not b or e: print('learn') print('learn') elif c and b and e: if not d or e and c and a: print('code') print('mastery') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 13: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, True, False, True. [2] Check condition (d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b or c and e). If it evaluates to True, print finxter to the shell. Otherwise, check condition (d or not b or e). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (c and b and e). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not d or e and c and a). If it evaluates to True, print code to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' code mastery ''' # Puzzle 14 a, b, c, d, e = False, False, False, False, False if c and not b or a and not d: if d or b and not c or a: print('finxter') elif d and a: print('42') print('learn') elif not b or b and e: if b and c or not e and not c: print('mastery') print('finxter') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 14: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, False, False, False. [2] Check condition (c and not b or a and not d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d or b and not c or a). If it evaluates to True, print finxter to the shell. Otherwise, check condition (d and a). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print learn to the shell. [5] Check the elif condition (not b or b and e). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (b and c or not e and not c). If it evaluates to True, print mastery to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' mastery finxter ''' # Puzzle 15 a, b, c, d, e = False, True, False, False, True if not c and c: if a or e and not d: print('mastery') elif e: print('yes') print('finxter') elif c: if c or d or b and e: print('yes') print('yes') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 15: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, False, False, True. [2] Check condition (not c and c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a or e and not d). If it evaluates to True, print mastery to the shell. Otherwise, check condition (e). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (c or d or b and e). If it evaluates to True, print yes to the shell. Otherwise, print yes. ''' # OUTPUT: ''' love ''' # Puzzle 16 a, b, c, d, e = False, False, True, True, True if e or b: if a: print('love') elif not e and not d or b: print('yes') print('code') elif c or not b: if a or e and c: print('42') print('yes') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 16: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, True, True, True. [2] Check condition (e or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print love to the shell. Otherwise, check condition (not e and not d or b). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print code to the shell. [5] Check the elif condition (c or not b). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (a or e and c). If it evaluates to True, print 42 to the shell. Otherwise, print yes. ''' # OUTPUT: ''' code ''' # Puzzle 17 a, b, c, d, e = True, False, False, False, False if d and c and a: if a: print('learn') elif not c: print('python') print('mastery') elif a or b: if e: print('yes') print('finxter') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 17: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, False, False, False. [2] Check condition (d and c and a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a). If it evaluates to True, print learn to the shell. Otherwise, check condition (not c). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (a or b). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (e). If it evaluates to True, print yes to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' finxter ''' # Puzzle 18 a, b, c, d, e = True, True, True, False, True if b or a: if not b or not d and a: print('learn') elif not c and c and b: print('42') print('love') elif c: if e and b: print('learn') print('python') else: print('code') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 18: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, True, False, True. [2] Check condition (b or a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not b or not d and a). If it evaluates to True, print learn to the shell. Otherwise, check condition (not c and c and b). If it evaluates to True, print 42 to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (c). If it evaluates to True, move on to the next step [6]. Otherwise, print code to the shell. [6] Check condition (e and b). If it evaluates to True, print learn to the shell. Otherwise, print python. ''' # OUTPUT: ''' learn love ''' # Puzzle 19 a, b, c, d, e = True, True, True, True, True if e: if not c or not d: print('mastery') elif d: print('finxter') print('python') elif d or not d or b: if d: print('yes') print('python') else: print('learn') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 19: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, True, True, True. [2] Check condition (e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not c or not d). If it evaluates to True, print mastery to the shell. Otherwise, check condition (d). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (d or not d or b). If it evaluates to True, move on to the next step [6]. Otherwise, print learn to the shell. [6] Check condition (d). If it evaluates to True, print yes to the shell. Otherwise, print python. ''' # OUTPUT: ''' finxter python ''' # Puzzle 20 a, b, c, d, e = True, True, True, True, True if not e and not c and d or b: if e and not d and b: print('love') elif e: print('finxter') print('42') elif not d and b or not e: if b: print('yes') print('finxter') else: print('finxter') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 20: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, True, True, True. [2] Check condition (not e and not c and d or b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (e and not d and b). If it evaluates to True, print love to the shell. Otherwise, check condition (e). If it evaluates to True, print finxter to the shell. In any case, move on to the next step [4]. [4] Print 42 to the shell. [5] Check the elif condition (not d and b or not e). If it evaluates to True, move on to the next step [6]. Otherwise, print finxter to the shell. [6] Check condition (b). If it evaluates to True, print yes to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' finxter 42 ''' # Puzzle 21 a, b, c, d, e = False, False, False, True, True if b: if d or not c and a: print('love') elif e or a: print('learn') print('love') elif e and d: if not d: print('code') print('yes') else: print('42') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 21: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, False, True, True. [2] Check condition (b). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d or not c and a). If it evaluates to True, print love to the shell. Otherwise, check condition (e or a). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (e and d). If it evaluates to True, move on to the next step [6]. Otherwise, print 42 to the shell. [6] Check condition (not d). If it evaluates to True, print code to the shell. Otherwise, print yes. ''' # OUTPUT: ''' yes ''' # Puzzle 22 a, b, c, d, e = False, True, True, False, False if e or not e: if b and d and not a or not e: print('yes') elif a and b: print('love') print('mastery') elif b and not a and d: if e or d and not c: print('love') print('finxter') else: print('finxter') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 22: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, True, False, False. [2] Check condition (e or not e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and d and not a or not e). If it evaluates to True, print yes to the shell. Otherwise, check condition (a and b). If it evaluates to True, print love to the shell. In any case, move on to the next step [4]. [4] Print mastery to the shell. [5] Check the elif condition (b and not a and d). If it evaluates to True, move on to the next step [6]. Otherwise, print finxter to the shell. [6] Check condition (e or d and not c). If it evaluates to True, print love to the shell. Otherwise, print finxter. ''' # OUTPUT: ''' yes mastery ''' # Puzzle 23 a, b, c, d, e = True, True, True, True, False if e or d or a: if d or not d or b or not e: print('learn') elif b and e or a: print('mastery') print('finxter') elif e: if c and a: print('code') print('code') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 23: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, True, True, False. [2] Check condition (e or d or a). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d or not d or b or not e). If it evaluates to True, print learn to the shell. Otherwise, check condition (b and e or a). If it evaluates to True, print mastery to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (e). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (c and a). If it evaluates to True, print code to the shell. Otherwise, print code. ''' # OUTPUT: ''' learn finxter ''' # Puzzle 24 a, b, c, d, e = True, True, True, True, True if a and not e or e: if a and d: print('finxter') elif d or not c and b: print('yes') print('finxter') elif e: if not a or a: print('learn') print('learn') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 24: [1] Create and initialize 5 variables: a, b, c, d, e = True, True, True, True, True. [2] Check condition (a and not e or e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (a and d). If it evaluates to True, print finxter to the shell. Otherwise, check condition (d or not c and b). If it evaluates to True, print yes to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (e). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not a or a). If it evaluates to True, print learn to the shell. Otherwise, print learn. ''' # OUTPUT: ''' finxter finxter ''' # Puzzle 25 a, b, c, d, e = False, False, False, False, False if not b or c and e: if d or not a or c and a: print('yes') elif c or a: print('python') print('finxter') elif e: if not e and a or c and d: print('code') print('code') else: print('mastery') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 25: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, False, False, False. [2] Check condition (not b or c and e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (d or not a or c and a). If it evaluates to True, print yes to the shell. Otherwise, check condition (c or a). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (e). If it evaluates to True, move on to the next step [6]. Otherwise, print mastery to the shell. [6] Check condition (not e and a or c and d). If it evaluates to True, print code to the shell. Otherwise, print code. ''' # OUTPUT: ''' yes finxter ''' # Puzzle 26 a, b, c, d, e = False, True, True, False, False if d and b or e: if b and d and c or a: print('mastery') elif b: print('python') print('love') elif a and not d: if e and not e: print('mastery') print('42') else: print('yes') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 26: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, True, False, False. [2] Check condition (d and b or e). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and d and c or a). If it evaluates to True, print mastery to the shell. Otherwise, check condition (b). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print love to the shell. [5] Check the elif condition (a and not d). If it evaluates to True, move on to the next step [6]. Otherwise, print yes to the shell. [6] Check condition (e and not e). If it evaluates to True, print mastery to the shell. Otherwise, print 42. ''' # OUTPUT: ''' yes ''' # Puzzle 27 a, b, c, d, e = False, True, True, False, False if not d: if c or b and not c: print('finxter') elif b: print('learn') print('finxter') elif b or c and not d: if not c and a or b: print('code') print('yes') else: print('love') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 27: [1] Create and initialize 5 variables: a, b, c, d, e = False, True, True, False, False. [2] Check condition (not d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (c or b and not c). If it evaluates to True, print finxter to the shell. Otherwise, check condition (b). If it evaluates to True, print learn to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (b or c and not d). If it evaluates to True, move on to the next step [6]. Otherwise, print love to the shell. [6] Check condition (not c and a or b). If it evaluates to True, print code to the shell. Otherwise, print yes. ''' # OUTPUT: ''' finxter finxter ''' # Puzzle 28 a, b, c, d, e = True, False, True, True, False if b and d or a or c: if b and a or not c or d: print('code') elif not d and a or c: print('python') print('finxter') elif c or not a and not e: if d and a: print('finxter') print('mastery') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 28: [1] Create and initialize 5 variables: a, b, c, d, e = True, False, True, True, False. [2] Check condition (b and d or a or c). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (b and a or not c or d). If it evaluates to True, print code to the shell. Otherwise, check condition (not d and a or c). If it evaluates to True, print python to the shell. In any case, move on to the next step [4]. [4] Print finxter to the shell. [5] Check the elif condition (c or not a and not e). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (d and a). If it evaluates to True, print finxter to the shell. Otherwise, print mastery. ''' # OUTPUT: ''' code finxter ''' # Puzzle 29 a, b, c, d, e = False, False, False, True, True if e and c and not d: if not d and not c: print('learn') elif d and e: print('code') print('python') elif b: if d: print('code') print('learn') else: print('python') ''' SOLUTION HINTS: Let's go over the relevant parts of puzzle 29: [1] Create and initialize 5 variables: a, b, c, d, e = False, False, False, True, True. [2] Check condition (e and c and not d). If it evaluates to True, move on the the next step [3]. Otherwise, enter step [5]. [3] Check condition (not d and not c). If it evaluates to True, print learn to the shell. Otherwise, check condition (d and e). If it evaluates to True, print code to the shell. In any case, move on to the next step [4]. [4] Print python to the shell. [5] Check the elif condition (b). If it evaluates to True, move on to the next step [6]. Otherwise, print python to the shell. [6] Check condition (d). If it evaluates to True, print code to the shell. Otherwise, print learn. ''' # OUTPUT: ''' python '''
Where to Go From Here?
Congratulations, you made it through all the code puzzles on this site. Did you enjoy to train your rapid code understanding by solving code puzzles? Great, then solve more puzzles for free on Finxter.com!
And share this blog article with a friend to challenge him as well. π