I only entered 2 of the 5 proposed contests, because either I was away when it was posted, or I couldn't think of an acceptable solution . My solutions were far from optimal and consequently didn't earn me much points, but I thought I'd share them with you guys anyways.
Code:
```For(A,1,256    For(B,1,sum(not(L1-A       A->L2(1+dim(L2    End End L2->L1```

Basically, this just figures out how many 1s there are in the initial list, then adds that many to the final list, then works it's way through all 256 integers... very slow, but also very small Code:
```DelVar D" ->Str3 While length(Str1)/6!=int(length(Str1)/6    Str1+"A->Str1    D+1->D End For(G,1,length(Str1),6    DelVar BFor(A,5,0,~1       B+29^A(inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ., ",sub(sub(Str1,G,6),abs(A-6),1))-1->B    End    For(A,3,0,~1       int(B/157^A->C    Str3+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZtheta0123456789[i]pi[e]?(){}[]+-*/^~!=!=>>=<<=^^o^^r^^Tplotsquareplotcross ^^2^^3^^-1randRadiancuberoot(xrootsqrt(ln(log(sin(cos(tan(sin^-1(cos^-1(tan^-1(e^(10^(|E|LSortA(SortD(dim(Fill(seq(augment(abs(round(iPart(fPart(int(min(max(Line(Tangent(Shade(Circle(Text(Pt-On(Pt-Off(Pt-Change(Pxl-On(Pxl-Off(Pxl-Change(pxl-Test(cosh(cosh^-1(sinh(tanh(tanh^-1(sinh^-1(fMax(fMin(Horizontal Vertical not( or fMin(fMax(AnsMenu(Output(If ThenElseFor(While Repeat EndPause Lbl Goto ReturnStopPrompt Disp DispGraphDispTablegetKeyClrHomeClrTableDrawF DrawInv >Frac>DecIS>(DS<(Input SciEngPolar",C+1,1->Str3                B-157^AC->B          End:End          {0,1->L1          {0,D->L2          LinReg(ax+b) {Y1}          Equ>String({Y1},Str1          sub(Str1,1,1)+sub(Str3,2,length(Str3)-1->Str1```

This is more of a brute force kind of approach in the sense that it's compression ratio is directly proportional to the number of one byte tokens I could cram in. I know there are more one byte tokens, however, some simple power juggling indicates that I needed 157 tokens to cover all combinations. Basically, it considers a string of 6 characters, which can be any combination of the 29 available characters, then created a decimal number representing which combination the characters are (for example, AAAAAA would be 1, AAAAAB would be 2 and so on), then it just creates a string from the 157 tokens availalbe to it that is that number, but only has to be 4 characters long, since it has more tokens to choose from. Essentially, it is converting a base 29 number into a base 157 number, except that the characters that represent the numbers are 1 byte tokens. it gets a compression ratio of about 30-32%, because it adds a little at the end of the input string to make it's length a multiple of 6.
Your task 1 was halfway to the fast solutions earthnite or jonbush, PT_, Runer112, and I had. Counting sort has the same idea; it's just that the frequencies of all numbers in an array can all be counted at once in one pass through the array.

First, you could have saved a byte and a small amount of speed using sum(L1=A. Then note that you're not using B as a variable. B, if it is saved between runs of the inner loop, can be used to point to the position in L2 to store to, saving the addition and call to dim( every time through:

Code:
```1->B For(A,1,256    For(B,B,sum(L1<=A       A->L2(B    End End L2->L1```

Say the list contains 3 ones and no twos. Then in the first iteration A=1, sum(L1<=A is 3 and the first 3 elements of L2 will be stored with 1. Then B will contain 4. The next iteration with A=2, the inner loop will be skipped since sum(L1<=A is still 3 and B is 4.

Then the only remaining differences between the code and the others are a more efficient computation of sum(L1<=A and use of [recursiven] for a slight additional speed boost.

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are GMT - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum