7 kyu
Natural Emptiness
176 of 278saudiGuy
Description:
Task
In abstract set theory, a construction due to von Neumann represents the natural numbers by sets, as follows:
- 0 = [ ] is the empty set
- 1 = 0 ∪ [ 0 ] = [ 0 ] = [ [ ] ]
- 2 = 1 ∪ [ 1 ] = [ 0, 1 ] = [ [ ], [ [ ] ] ]
- n = n−1 ∪ [ n−1 ] = ...
Write a function that receives an integer n
and produces the representing set.
Examples
rep_set(0) ➞ []
rep_set(1) ➞ [[]]
rep_set(2) ➞ [[], [[]]]
rep_set(3) ➞ [[], [[]], [[], [[ ]]]]
Input Constraints
- 0 <= n <= 15
- Code limit is <= 200 characters for Python and <= 300 characters for TypeScript and JavaScript.
Algorithms
Set Theory
Recursion
Similar Kata:
Stats:
Created | Jul 20, 2023 |
Published | Jul 20, 2023 |
Warriors Trained | 693 |
Total Skips | 14 |
Total Code Submissions | 804 |
Total Times Completed | 278 |
Python Completions | 176 |
JavaScript Completions | 99 |
TypeScript Completions | 26 |
Total Stars | 7 |
% of votes with a positive feedback rating | 90% of 55 |
Total "Very Satisfied" Votes | 45 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 20 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |