Folks,

I thought I would put out this challenge, as each time I work on it I get 
in  intellectual loops. Whilst I would appreciate others having a go it is 
also to put out a challenge for new and experienced users alike and can 
produce a useable set of code patterns.

* The Idea*

Take an Arbitrary character set as defined in this macro;
\define char-set() 
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
 
I would like to generate a serial number for tiddlers but convert them to 
this character set which is even more compact than HEX (Which has 16 
possible values) this character set is strait forward but has 10+26+26 or 
62 characters. That is 5 characters can represent up to the decimal 916,132,832 
- yes that is almost a billion. and 6 characters to 56,800,235,584 Wow!
.
Now we may also want a way to convert (large) decimal numbers to this 
character set or values in this character set back to decimal.

*Background;*
Each new tiddler can be issued with a serial number, add one for the next, 
however all we need is such number to be unique, so before saving it in a 
tiddler we can compress it before saving for a tiddler. In this case we 
convert it to base 62. We may never need to reverse this, however being 
able to do so is a useful exercise.

   - You could use this type of set up to "encrypt content" that will not 
   work unless the character set is provided (of course these can be cracked) 
   but for fun.


   - A carefully crafted solution could just have the character set changed 
   for conversions between any number base system decimal, octal, 
   hexadecimal,  binary and even arbitrary ones like mine above base 62

*Here are some code fragments*
<$set name=base filter="[<char-set>split[]count[]]">
This set will count the characters in the character set and tell us what 
the numeric base is.

Input <$edit-text  tiddler=temp field="input-number"/> [[temp]]
This accepts input of a number or string we may convert

<$set name=number filter="[[temp]get[input-number]]">
This sets the number provided to a variable

<$set name=size filter="[<number>length[]]">
This gets the size of the number or string

With the new power operator we can compute values to the power of 1, 2, 3...

{{{ [<char-set>split[]nth<position>] }}}
This will return a character from out character set in the nth <<position>>

Like any code challenge the winner as judged by each of us individually, is 
the most elegant, easiest to read, efficient etc... 

Most of all, have fun. Yes I may compete in this challenge as well.

Tones

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c1c642e5-10e5-46bd-a721-07fa4091c98en%40googlegroups.com.

Reply via email to