Calculator Community > Community Contests
[ENDED] Code Golf - The Reboot #5
JWinslow23:
Everybody back off, I'm taking back this contest :P
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 :P
Without further ado...
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
--- End code ---
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
--- End code ---
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
--- End code ---
Your mission: Help yourthelf find your keith!
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... :P
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.
TI-BASIC
RankUserSizeDate1@lirtosiast43Jul 01 2015 02:25:25 pm2@PT_43Jul 02 2015 01:24:20 pm3@mr womp womp97Jun 30 2015 09:13:00 pm
Lua
RankUserSizeDate1@Adriweb152Jun 30 2015 02:06:20 am
Javascript
RankUserSizeDate1@Adriweb112Jun 30 2015 02:06:20 am
Java
RankUserSizeDate1@c4ooo190Jul 01 2015 12:32:49 pm
Ruby
RankUserSizeDate1@Juju150Jun 30 2015 04:57:53 pm
Python
RankUserSizeDate1@Cumred_Snektron83Jul 01 2015 10:37:07 am
Language Ranking
RankLangUserSizeDate1TI-BASIC@lirtosiast43Jul 01 2015 02:25:25 pm2Python@Cumred_Snektron83Jul 01 2015 10:37:07 am3Javascript@Adriweb112Jun 30 2015 02:06:20 am4Ruby@Juju150Jun 30 2015 04:57:53 pm5Lua@Adriweb152Jun 30 2015 02:06:20 am6Java@c4ooo190Jul 01 2015 12:32:49 pm
As I am having trouble with formatting, everyone's code has been put in a Pastebin paste here.
c4ooo:
Can the output for "false" be an infinite stream of "false"-s?
And can the output for "true" be an infinite stream of "false"-s? with a "true" somewhere in the middle?
Other than that i'm about done :D
JWinslow23:
--- Quote from: c4ooo on June 29, 2015, 06:30:06 pm ---Can the output for "false" be an infinite stream of "false"-s?
And can the output for "true" be an infinite stream of "false"-s? with a "true" somewhere in the middle?
Other than that i'm about done :D
--- End quote ---
No. The stream cannot be infinite. But it must somehow be unique for true and false, and distinguishable.
Oh, and it must be the same for all truthy and falsy results.
c4ooo:
--- Quote from: JWinslow23 on June 29, 2015, 07:54:06 pm ---
--- Quote from: c4ooo on June 29, 2015, 06:30:06 pm ---Can the output for "false" be an infinite stream of "false"-s?
And can the output for "true" be an infinite stream of "false"-s? with a "true" somewhere in the middle?
Other than that i'm about done :D
--- End quote ---
No. The stream cannot be infinite. But it must somehow be unique for true and false, and distinguishable.
--- End quote ---
Actually my conditional exit turned out to be smaller then an infinite one :P
--- Quote from: JWinslow23 on June 29, 2015, 07:54:06 pm ---Oh, and it must be the same for all truthy and falsy results.
--- End quote ---
However this part may trip me up about 20 bytes :(
Edit: I presume the only input provided is the integer to be tested, 'N' and that 'D' is not provided. Am i right?
JWinslow23:
--- Quote from: c4ooo on June 29, 2015, 08:05:57 pm ---
--- Quote from: JWinslow23 on June 29, 2015, 07:54:06 pm ---
--- Quote from: c4ooo on June 29, 2015, 06:30:06 pm ---Can the output for "false" be an infinite stream of "false"-s?
And can the output for "true" be an infinite stream of "false"-s? with a "true" somewhere in the middle?
Other than that i'm about done :D
--- End quote ---
No. The stream cannot be infinite. But it must somehow be unique for true and false, and distinguishable.
--- End quote ---
Actually my conditional exit turned out to be smaller then an infinite one :P
--- Quote from: JWinslow23 on June 29, 2015, 07:54:06 pm ---Oh, and it must be the same for all truthy and falsy results.
--- End quote ---
However this part may trip me up about 20 bytes :(
Edit: I presume the only input provided is the integer to be tested, 'N' and that 'D' is not provided. Am i right?
--- End quote ---
Yes. D is simply to illustrate the number of digits in a way that wasn't int(log(N))+1 :P
Navigation
[0] Message Index
[#] Next page
Go to full version