Talk:Ludic numbers: Difference between revisions

m
→‎Task description generator: Belated signing of entry.
m (→‎Task description generator: Belated signing of entry.)
 
(2 intermediate revisions by the same user not shown)
Line 11:
 
: Improved. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 10:31, 16 March 2014 (UTC)
 
==Task description generator==
Somewhere to stash it.
<lang python>from nth import nth
 
def _parray(array, indexed=None, nmax=25):
lst = array[:nmax]
return ('<code>' +
( ('<span style="color:blue;font-weight:bold"><s>%i</s></span> ' % lst[0])
if indexed else
('<span style="color:blue;font-weight:bold">%i</span> ' % lst[0]) ) +
' '.join( (('%i' % l)
if not indexed or i % indexed
else ("<s>%i</s>" % l))
for i, l in enumerate(lst[1:], 1) )
+ ' ...</code>')
 
def ludicpr(nmax=100, prloops=4):
print('The first ludic number is <span style="color:blue;font-weight:bold">1</span>.')
#yield 1
print('<br>To generate succeeding ludic numbers create an array of '
'increasing integers starting from 2')
lst = list(range(2, nmax + 1))
print(':%s' % _parray(lst))
print('(Loop)')
i = 0
while lst and i <prloops:
i += 1
print('* Take the first member of the resultant array as the next Ludic number '
'<span style="color:blue;font-weight:bold">%i</span>.' % lst[0])
#yield lst[0]
print("* Remove every '''%s''' indexed item from the array (including the first)." % nth(lst[0]))
print('::%s' % _parray(lst, indexed=lst[0]))
del lst[::lst[0]]
if i == 1:
print('* (Unrolling a few loops...)')
print("""\
* ...
* Take the first member of the current array as the next Ludic number <span style="color:blue;font-weight:bold">L</span>.
* Remove every '''L'th''' indexed item from the array (including the first).
* ...""")</lang> --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 06:59, 19 April 2014 (UTC)
Anonymous user