Everybody back off, I'm taking back this contest

Hello, Omnimaga/CodeWalrus/Cemetech/my girlfriend/whoever is seeing this right now, and welcome to the fifth installment of...
Code Golf: The Reboot

As you can see, I'm neither @pimathbrainiac NOR @c4ooo , NOT EVEN @Juju , but I am the original @JWinslow23, the one who came up with this silly idea in the first place almost a year ago. However, don't expect me to host next time, or basically for the next few competitions. How it works is, there's this cycle of hosts that will successively host this competition, starting with pimath. Somewhere in that loop, there's yours-truly, with a challenge on deck to give you. This is that.

Don't know what code golf is? Check out this contest thread OR this really old contest thread for an explanation. Don't know what code is? Then you will not understand this website in general

Challenge 5

Problem

You, a person with a lisp, go to your car, and unlock it with the keys...but there's one problem...you don't have your keys with you.

"Oh no...I lotht my keith! Where'th my car keith?" you exclaim in nervousness. You know that you have more than one pair, but you can't for the life of you find any of them.

Suddenly, you remember...each of your keys had a number on it 10 or above, each of which you call a Keys Number, or "Keith Number". Now, these numbers have a special property:

For a number N with D digits, if you arranged the digits to make a Fibonacci-like sequence where the digits of N are the first few terms, and each number is the sum of the D preceding digits, it would have N somewhere in the sequence.

Examples:

14 is a Keith Number:
Code:
```N = 14 D = 2 1 + 4 = 5 4 + 5 = 9 5 + 9 = 14```
197 is a Keith Number:
Code:
```N = 197 D = 3 1 + 9 + 7 = 17 9 + 7 + 17 = 33 7 + 17 + 33 = 57 17 + 33 + 57 = 107 33 + 57 + 107 = 197```
1337 is NOT a Keith Number:
Code:
```N = 1337 D = 4 1 + 3 + 3 + 7 = 14 3 + 3 + 7 + 14 = 27 3 + 7 + 14 + 27 = 51 7 + 14 + 27 + 51 = 99 14 + 27 + 51 + 99 = 191 27 + 51 + 99 + 191 = 368 51 + 99 + 191 + 368 = 709 99 + 191 + 368 + 709 = 1367```

Make a program that, given an integer input 10 or above, will tell you whether or not it is a Keith number.

Any output is permitted, but the output must be different for a truthy and falsy result, and the two different outputs must be specified to me so I know the difference. Finally, if the size of the program is exactly 1337 bytes...then that'd be kinda cool...

Scoring

All non-calc languages will be scored with this counter.
Assembly and compiled Axe programs will be scored on binary size (minus the header), and TI-BASIC will be scored on on-calc source size (again, minus the header).

Submission

PM me over on Omnimaga, Cemetech, or CodeWalrus, or tell my girlfriend and have her dictate the code to me. (If you take the latter option, I will give your code a -90% point bonus. I'm serious.)

Good luck! Remember, don't steal code from others; I want everyone to not fib and not cheat.

EDIT: THE CONTEST IS OVER! Head over to Codewalrus or Omnimaga for a nicely formatted table of the winners.
Alrighty, just completed the program that will do just that, but will now try to optimize, it is currently 97 bytes in ti-basic, without the header, I will send it to you when I feel it can't be optimized further.
VoilĂ , 87 bytes in TI-BASIC
Do you need something like
Code:
`Input N`
?

EDIT: 83 bytes, with the input

EDIT2: 68 bytes
PT_ wrote:
VoilĂ , 87 bytes in TI-BASIC
Do you need something like
Code:
`Input N`
?

EDIT: 83 bytes, with the input

EDIT2: 68 bytes

You need some way to input numbers, whether it's Ans or with an Input, or whatever. Just explain it to me.

EDIT: Updated the winners so far! Check out the links in the post to see who's winning!
Is this allowed? Disp each time "0", until you have a Keith number, and then "1"? Or must the output only 1 word, token or so? Because then I can save 2 bytes.

EDIT: who can beat me? 50 bytes
PT_ wrote:
Is this allowed? Disp each time "0", until you have a Keith number, and then "1"?

Crossposting this contest to bring other site users in on it is great, but unfortunately you couldn't see that this has already been addressed in Omnimaga's version of the thread. I'll reproduce the relevant section of the relevant post:

JWinslow23 wrote:
Runer112 wrote:
Are the following acceptable truthy and falsy results:

• 2 and 0
• no error and error
• 1 and no output

2 and 0 is acceptable, no error and error is not acceptable acceptable only if the output is the same for every truth and the same for every false, 1 and no output is acceptable. Also, the output for truth and false must be the exact same to the letter for every truth and false result.

Based on these rules, your suggested output format is unfortunately not allowed.
8 entries have been received! And it looks like there was a heated competition over in TI-BASIC for a while. My personal best is 51 in that language, but the top two entries (48 and 43) beat it! Keep up the good work, golfers!
The contest is over! I hope everybody had fun with this challenge!
I just got back from a small trip, I haven't won, but before I left, I had tried the biggest known keith number on my prog (5752090994058710841670361653731519) just to see if it would identify it as a keith number, and it did, then I incremented it by 1 and by a few other numbers to see if it just rounded it off or something, and oddly enough, it returned a negative result for the numbers that aren't actual keith numbers, I'm suspecting its because each digit is stored to a list which somehow makes the 14 digit thing not a problem? I'd like to know for sure tho, here is my code, if anyone knows what's going on here, plz help xD

Code:
```Input Str1 expr(Str1->B ClrList L2 For(A,1,length(Str1 expr(sub(Str1,A,1->L2(1+dim(L2 End Repeat E>B sum(L2->E If E=B:Disp 1 DeltaList(cumSum(L2->L2 augment(L2,{E->L2 End```

Basically i'm just asking for a number, then storing it to a list, then storing the sum of that list to E, then removing the first element of the list and adding E at the end and doing the sum of that new list and repeat that loop until either it finds the numbers are equal and displays a 1, or it goes over the initial number, in which case, its not a keith number so it stops without displaying anything.
mr womp womp wrote:
I just got back from a small trip, I haven't won, but before I left, I had tried the biggest known keith number on my prog (5752090994058710841670361653731519) just to see if it would identify it as a keith number, and it did, then I incremented it by 1 and by a few other numbers to see if it just rounded it off or something, and oddly enough, it returned a negative result for the numbers that aren't actual keith numbers, I'm suspecting its because each digit is stored to a list which somehow makes the 14 digit thing not a problem? I'd like to know for sure tho, here is my code, if anyone knows what's going on here, plz help xD

Code:
```Input Str1 expr(Str1->B {expr(sub(Str1,1,1->L2 For(A,2,length(Str1 augment(L2,{expr(sub(Str1,A,1->L2 End Repeat E>B sum(L2->E If E=B:Disp 1 DeltaList(cumSum(L2->L2 augment(L2,{E->L2 End```

Basically i'm just asking for a number, then storing it to a list, then storing the sum of that list to E, then removing the first element of the list and adding E at the end and doing the sum of that new list and repeat that loop until either it finds the numbers are equal and displays a 1, or it goes over the initial number, in which case, its not a keith number so it stops without displaying anything.

See, TI-BASIC only has a precision of up to 14 digits without losing accuracy. Which means that numbers that high are expected to produce unexpected results. If some sort of arbitrary precision arithmetic system were developed and used, I bet we could test Keith numbers with hundreds of digits...given enough speed and time...

Code:
``` ClrList L2 For(A,1,length(Str1 expr(sub(Str1,A,1->L2(1+dim(L2 End ```

This is equivalent to seq(sub(Str1,A,1),A,1,length(Str1.

Not sure why (or even if) it works, but note that the calculator can't handle the number 5752090994058710841670361653731519, and truncates it to 5.752090994ᴇ33 or 57520909940000000000000000000000000.

Also, how would it "return a negative result"? It'll either display 1 or nothing.
M. I. Wright wrote:

Code:
``` ClrList L2 For(A,1,length(Str1 expr(sub(Str1,A,1->L2(1+dim(L2 End ```

This is equivalent to seq(sub(Str1,A,1),A,1,length(Str1.

Not sure why (or even if) it works, but note that the calculator can't handle the number 5752090994058710841670361653731519, and truncates it to 5.752090994ᴇ33 or 57520909940000000000000000000000000.

Also, how would it "return a negative result"? It'll either display 1 or nothing.

okay well, first of all, no it isnt equivalent to that, just tried replacing it and just returns an error, by returns a negative result, I meant that it doesn't display anything, which is what it does when the number isn't a keith number. Thats why I find it odd that it correctly identifies 575209099405871084167036165373151 as a keith number, and also correctly identifies that numbers around it aren't, since it's supposed to just round it off after 14 digits...
My bad, it's seq(expr(sub(Str1,A,1)),A,1,length(Str1 - and I see what you meant by "negative" now, I thought you meant it as "a negative number".

The reason it doesn't just round it off is because you have it input to a string, as you suspected-- the B variable, though, is stored as 5.752090994ᴇ33.
M. I. Wright wrote:
My bad, it's seq(expr(sub(Str1,A,1)),A,1,length(Str1 - and I see what you meant by "negative" now, I thought you meant it as "a negative number".

The reason it doesn't just round it off is because you have it input to a string, as you suspected-- the B variable, though, is stored as 5.752090994ᴇ33.

Yeah uhm, your code uses the A variable, if you take out the for loop, the A variable can't have a use, since it is incremented in the for loop... if your code is intended to be used inside the for loop instead of

Code:
`expr(sub(Str1,A,1->L2(1+dim(L2 `

then my code is smaller... and since each digit from that string is added onto the List one at a time, it can't just round it off. still wondering how on earth some people got it down to 43 bytes lol, I mean even if your code works and I'm doing something wrong with it, it would only chop mine down to somewhere in the 70s, nowhere near 43...
if the guy who did it wants to post his code, I'd be happy to stare at it for a while, see what I did wrong

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 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