Anonymous user
Index finite lists of positive integers: Difference between revisions
Index finite lists of positive integers (view source)
Revision as of 22:28, 7 September 2018
, 5 years agoadded a ;Task: section header, added whitespace and bullets to the task's preamble..
m (→{{header|REXX}}: added comments, added whitespace, used more decimal digits and a bigger integer, added wording to the REXX section header..) |
m (added a ;Task: section header, added whitespace and bullets to the task's preamble..) |
||
Line 1:
{{draft task}}
It is known that the set of finite lists of positive integers is [[wp:countable| <u>countable</u>)]].
* write a function ''unrank'' which is ''rank'' 's [[wp:inverse function|inverse function]].▼
;Task:
<br>Demonstrate your solution by picking a random-length list of random positive integers, turn it into an integer and get the list back.▼
Implement such a mapping:
:* write a function ''rank'' which assigns an integer to any finite, arbitrarily long list of arbitrary large positive integers.
▲:* write a function ''unrank'' which is the ''rank''
There are many ways to do this. Feel free to choose any one you like.▼
Demonstrate your solution by:
▲
:* turn it into an integer, and
:* get the list back.
'''Extra credit''':▼
▲There are many ways to do this. Feel free to choose any one you like.
Make the ''rank'' function as a [[wp:bijection| <u>bijection</u>]] and show ''unrank(n)'' for <big>'''n'''</big> varying from '''0''' to '''10'''.
<br><br>
|