Weregoose wrote:
souvik1997 wrote:
I completed the challenge, so I get to create the next one >Smile!

Prove it!


Quote:
I will upload the program tomorrow with the source, as I'm too lazy to get it off my calculator right now
Weregoose wrote:
souvik1997 wrote:
I completed the challenge, so I get to create the next one >Smile!

Prove it!

We'll move ahead when everyone's had a chance to show off and share.
Seconded, let's wait to see who else finished it and which everyone thinks is the best. Weregoose, did you also make a version?
When I see what everyone else did, I'll modify my version accordingly.
Weregoose wrote:
When I see what everyone else did, I'll modify my version accordingly.
Hmmm, why does that sound vaguely like cheating to me? Cool
KermMartian wrote:
Weregoose wrote:
When I see what everyone else did, I'll modify my version accordingly.
Hmmm, why does that sound vaguely like cheating to me? Cool

I didn't want to do this, my friend, but you've forced my hand.

Dice roll in L1.

Code:
:sum(L1=median(L1→X
:max(not(fPart(prod(2L1+1-7(L1=4))/{210,770,2002
:Ans+6not(AnsfPart(2variance(L1
:If X=3
:2+(2=sum(L1=max(L1not(L1=median(L1
:If X>3
:X
:sub("S3H4YCL",Ans,1

3 = Three-of-a-kind
4 = Four-of-a-kind
H = Full house
S = Small straight
L = Large straight
Y = Yahtzee
C = Chance
And as expected, you did not fail me. That's some amazing code right there. Would you mind explaining what variance() is for in this context?
Statistics? What are statistics? I only look at the numbers.

In the case of five elements, the sample variation may as well be equal to sum(Ans²)/4-sum(Ans)²/20.

All 15 ways to get small straights, and their variances, are:

Code:
1,1,2,3,4   1.7
1,2,2,3,4   1.3
1,2,3,3,4   1.3
1,2,3,4,4   1.7
1,2,3,4,5   2.5
1,2,3,4,6   3.7
2,2,3,4,5   1.7
2,3,3,4,5   1.3
2,3,4,4,5   1.3
2,3,4,5,5   1.7
2,3,4,5,6   2.5
3,3,4,5,6   1.7
3,4,4,5,6   1.3
3,4,5,5,6   1.3
3,4,5,6,6   1.7

Hello, 2.5's!

I don't use this function much outside of asking, "are all these numbers equal," but here I felt that it was the right tool for shedding light on the sort of unique trait that a five-of-a-kind would carry – that they would be the only two instances among this particular pool of numbers where the middle element would be "pulled" by the same amount in both directions.

One teensy problem: in a game of Yahtzee, taking a Chance on 6,6,6,5,5 yields a higher score than a full house would. There are probably other examples, but for now I'll conclude (rather unscientifically) that it isn't strategically better to do so.

And I can't wait to get into the philosophical infeasibility of the next challenge. Most people will not agree with me.
My program is slightly different, it scores the dice as many ways as possible and outputs the scores in L2. L2's format is as follows:

Code:
L2={1's,2's,3's,4's,5's,6's,3 of a kind, 4 of a kind, Small Straight, Large Straight, Full House, Chance, Yahtzee (1 if Yahtzee is possible, else 0)}

L2 will hold all the scores for each category in their appropriate positions in the list.

Here is my program:
BASIC Code wrote:
:1Ans→L1
:13→dim(L2
:For(X,1,6
:¦ For(Y,1,5
:¦ ¦ If L1(Y)=X
:¦ ¦ A+1→A
:¦ End
:¦ XA→L2(X
:¦ DelVar A
:End
:For(X,1,6
:¦ For(Y,1,5
:¦ ¦ If L1(Y)=X
:¦ ¦ A+1→A
:¦ End
:¦ A→∟TMP(X
:¦ DelVar A
:End
:For(X,1,6
:¦ If ∟TMP(X)=3
:¦ sum(L1→L2(7
:¦ If ∟TMP(X)=4
:¦ sum(L1→L2(8
:End
:DeltaList(L1→L3
:SortD L3
:If 0<L3(1
:SortA L3
:1→X
:Repeat L3(X) or X=4
:¦ X+1→X
:¦ If X=3
:¦ 30→L2(9
:¦ If X=4
:¦ 40→L2(10
:End
:SortA L1
:abs(DeltaList(L1→L3
:SortA L3
:3→dim(L3
:If 3=sum(L3=(0L3
:25→L2(11
:sum(L1→L2(12
:If not(sum(DeltaList(L1
:1→L2(13
:
Generated by SourceCoder, © 2005-2010 Cemetech
Looking good, Souvik, also a nice approach. Smile Thanks for sharing. Anyone else?
I'm thoroughly convinced that Weregoose codes like this:
1) randomly press buttons
2) say a few magic words
3) tada! magic.
More details:

If a number appears more than twice in a list of five, one of them is automatically the median. Line one counts how many and stores to X.

The second line converts 1–6 to primes, multiplies them together, and then divides by three "base" products corresponding to the small straights 1–4, 2–5, and 3–6 to see whether one of them is present. One or zero is stored in Ans, and no sorting is required.

Line three adds six for the "L" in the sub( if the variance test given in my earlier post is met. Additionally, six gets added to zero if there is no small straight.

If X=3—which is impossible if you have a small or large straight—then it places a two for the "3" in the sub(, as we now have a three-of-a-kind. Yet, it goes on to ask whether the maximum of the two items that aren't the median happens to equal the other. If so, then it adds another two for the "H" in the sub( to give us a full house.

If X>4, then it's a 4-of-a-kind or a Yahtzee, and their characters are already seated in their proper places inside the string. (The "C" is primed from earlier via the line for the large straight.)
*bump*

Has anyone else tried this challenge?
The "arbitrary string" compression? Not possible on account of the pigeonhole principle – the smallest possible bijection of a random data stream is onto itself. All compressions create redundancies. To retain all information, you must instantly "back up" the missing values, which is no compression at all. To argue for the presence of an algorithm that produces smaller versions of every value, you must be willing to admit inductively that this compressed stream is further compressible ad infinitum, down until all numbers are representable by a single bit of information. In brief, you need specialized routines for specialized data.

Compression is necessarily lossy.
Oh, ok then. In that case, you could make the next challenge.
I really hate being volunteered. It's only motive for everyone else to sit quietly.
Weregoose wrote:
I really hate being volunteered. It's only motive for everyone else to sit quietly.


Sorry. The next challenge is to make a program that converts a string to its getKey equivalents, like "A" becomes 41, without using a bunch of if/then statements.
souvik1997 wrote:
Weregoose wrote:
I really hate being volunteered. It's only motive for everyone else to sit quietly.


Sorry. The next challenge is to make a program that converts a string to its getKey equivalents, like "A" becomes 41, without using a bunch of if/then statements.
An excellent idea! I think I know the basic idea, but I'm sure other peoples' implementations will blow mine away. Nevertheless, I shall try.
Here's my take on the problem:
:Input Str1
:inString("ABC DEFGHIJKLMNOPQRSTUVWXYZ",Str1
:Ans+40+5int(.2(Ans-1
:Disp Ans
I think you need two spaces between C and D, do you not? Other than that, that's exactly what I was thinking too. Smile
I had the ")-1" on the first line, but same. The one space was due to the way HTML handles text outside of white-space: pre;. Wink
  
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.

» Go to Registration page
Page 2 of 3
» All times are UTC - 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

 

Advertisement