### Author Topic: [ENDED] Code Golf - The Reboot #5  (Read 13678 times)

0 Members and 1 Guest are viewing this topic.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### [ENDED] Code Golf - The Reboot #5
« on: June 29, 2015, 03:47:53 pm »
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: [Select]
N = 14D = 21 + 4 = 54 + 5 = 95 + 9 = 14197 is a Keith Number:
Code: [Select]
N = 197D = 31 + 9 + 7 = 179 + 7 + 17 = 337 + 17 + 33 = 5717 + 33 + 57 = 10733 + 57 + 107 = 1971337 is NOT a Keith Number:
Code: [Select]
N = 1337D = 41 + 3 + 3 + 7 = 143 + 3 + 7 + 14 = 273 + 7 + 14 + 27 = 517 + 14 + 27 + 51 = 9914 + 27 + 51 + 99 = 19127 + 51 + 99 + 191 = 36851 + 99 + 191 + 368 = 70999 + 191 + 368 + 709 = 1367Your 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...

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
 Rank User Size Date 1 @lirtosiast 43 Jul 01 2015 02:25:25 pm 2 @PT_ 43 Jul 02 2015 01:24:20 pm 3 @mr womp womp 97 Jun 30 2015 09:13:00 pm

Lua
 Rank User Size Date 1 @Adriweb 152 Jun 30 2015 02:06:20 am

Javascript
 Rank User Size Date 1 @Adriweb 112 Jun 30 2015 02:06:20 am

Java
 Rank User Size Date 1 @c4ooo 190 Jul 01 2015 12:32:49 pm

Ruby
 Rank User Size Date 1 @Juju 150 Jun 30 2015 04:57:53 pm

Python
 Rank User Size Date 1 @Cumred_Snektron 83 Jul 01 2015 10:37:07 am

Language Ranking
 Rank Lang User Size Date 1 TI-BASIC @lirtosiast 43 Jul 01 2015 02:25:25 pm 2 Python @Cumred_Snektron 83 Jul 01 2015 10:37:07 am 3 Javascript @Adriweb 112 Jun 30 2015 02:06:20 am 4 Ruby @Juju 150 Jun 30 2015 04:57:53 pm 5 Lua @Adriweb 152 Jun 30 2015 02:06:20 am 6 Java @c4ooo 190 Jul 01 2015 12:32:49 pm

As I am having trouble with formatting, everyone's code has been put in a Pastebin paste here.
« Last Edit: July 05, 2015, 02:13:37 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### c4ooo

• Project Author
• Posts: 252
• Rating: +10/-1
• The impossible chemical compound.
##### Re: Code Golf - The Reboot #5
« Reply #1 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
-German Kuznetsov
The impossible chemical compound.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Code Golf - The Reboot #5
« Reply #2 on: June 29, 2015, 07:54: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
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.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### c4ooo

• Project Author
• Posts: 252
• Rating: +10/-1
• The impossible chemical compound.
##### Re: Code Golf - The Reboot #5
« Reply #3 on: June 29, 2015, 08:05:57 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
No. The stream cannot be infinite. But it must somehow be unique for true and false, and distinguishable.
Actually my conditional exit turned out to be smaller then an infinite one

Oh, and it must be the same for all truthy and falsy results.
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?
« Last Edit: June 29, 2015, 08:12:08 pm by c4ooo »
-German Kuznetsov
The impossible chemical compound.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Code Golf - The Reboot #5
« Reply #4 on: June 29, 2015, 08:43:10 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
No. The stream cannot be infinite. But it must somehow be unique for true and false, and distinguishable.
Actually my conditional exit turned out to be smaller then an infinite one

Oh, and it must be the same for all truthy and falsy results.
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?
Yes. D is simply to illustrate the number of digits in a way that wasn't int(log(N))+1
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### c4ooo

• Project Author
• Posts: 252
• Rating: +10/-1
• The impossible chemical compound.
##### Re: Code Golf - The Reboot #5
« Reply #5 on: June 29, 2015, 10:04:29 pm »
Entry submitted, 217 bytes in java.
And also JWinslow please count compiled programs (axe included) in source size. @pimathbrainiac and I now both agree that all compiled languages should be counted in source size.
Edit: do you have a Programing Puzzles & Code Golf acount on stack overflow? If not can i cross post the question?
« Last Edit: June 29, 2015, 11:37:42 pm by c4ooo »
-German Kuznetsov
The impossible chemical compound.

#### Runer112

• Moderator
• LV11 Super Veteran (Next: 3000)
• Posts: 2289
• Rating: +639/-31
##### Re: Code Golf - The Reboot #5
« Reply #6 on: June 30, 2015, 09:21:55 am »
Are the following acceptable truthy and falsy results:
• 2 and 0
• no error and error
• 1 and no output

Is there a minimum input value up through which the program must return correct results?
« Last Edit: June 30, 2015, 09:41:08 am by Runer112 »

• Editor
• LV10 31337 u53r (Next: 2000)
• Posts: 1708
• Rating: +229/-17
##### Re: Code Golf - The Reboot #5
« Reply #7 on: June 30, 2015, 11:05:36 am »
Lua, 152
JS, 112.

(counted both with the "function K(n)" header)
My calculator programs
TI-Nspire Lua programming : Tutorials  |  API Documentation

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Code Golf - The Reboot #5
« Reply #8 on: June 30, 2015, 11:31:12 pm »
Entry submitted, 217 bytes in java.
And also JWinslow please count compiled programs (axe included) in source size. @pimathbrainiac and I now both agree that all compiled languages should be counted in source size.
Edit: do you have a Programing Puzzles & Code Golf acount on stack overflow? If not can i cross post the question?
Noted. Will change rules accordingly.
Also, if I do, I don't use it anymore.
Are the following acceptable truthy and falsy results:
• 2 and 0
• no error and error
• 1 and no output
Is there a minimum input value up through which the program must return correct results?
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.
And the minimum (also for determining them in the first place; 1 digit numbers are trivially Keith numbers) is 10. Which is not a Keith number (1+0, 0+1, 1+1, 1+2, 2+3, 3+5, 5+8...).
Lua, 152
JS, 112.

(counted both with the "function K(n)" header)
Counting the header (deducting the header only applies to TI-83/84/+/SE submissions) and accepting.
« Last Edit: June 30, 2015, 11:39:32 pm by c4ooo »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Code Golf - The Reboot #5
« Reply #9 on: June 30, 2015, 11:59:24 pm »
Updated!
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Runer112

• Moderator
• LV11 Super Veteran (Next: 3000)
• Posts: 2289
• Rating: +639/-31
##### Re: Code Golf - The Reboot #5
« Reply #10 on: July 01, 2015, 09:06:48 am »
And the minimum (also for determining them in the first place; 1 digit numbers are trivially Keith numbers) is 10. Which is not a Keith number (1+0, 0+1, 1+1, 1+2, 2+3, 3+5, 5+8...).

I meant is there a required point at least through which the program must behave correctly? Does an entry have to work for all inputs up to 100? 1000? 1000000?

#### c4ooo

• Project Author
• Posts: 252
• Rating: +10/-1
• The impossible chemical compound.
##### Re: Code Golf - The Reboot #5
« Reply #11 on: July 01, 2015, 12:28:45 pm »
If anyone want to know why there was some secrecy between me and JWinslow last night it was because i asked him if i could cross post this to Code golf on stackoverflow, and he said yes, except he did  not any 1 to find out. I ended up not doing it because there already is a keith testing challenge on the stackoverflow network
-German Kuznetsov
The impossible chemical compound.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Code Golf - The Reboot #5
« Reply #12 on: July 01, 2015, 12:40:03 pm »
And the minimum (also for determining them in the first place; 1 digit numbers are trivially Keith numbers) is 10. Which is not a Keith number (1+0, 0+1, 1+1, 1+2, 2+3, 3+5, 5+8...).

I meant is there a required point at least through which the program must behave correctly? Does an entry have to work for all inputs up to 100? 1000? 1000000?
The program should work up to 5752090994058710841670361653731519, or the maximum the language allows (e.g. for TI-BASIC, up to 14 digit numbers are perfectly acceptable).
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Code Golf - The Reboot #5
« Reply #13 on: July 03, 2015, 04:11:20 pm »
Bump.

Just a reminder, the contest ends officially at midnight EST tomorrow!

I have a (non-official, non-counted-at-all-but-I'll-still-show-it-at-the-end) entry in Golfscript that measures out to 40 bytes. A challenge for the next day...can YOU do better?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: [ENDED] Code Golf - The Reboot #5
« Reply #14 on: July 05, 2015, 02:15:31 pm »
The contest is over! I hope everybody had fun with this challenge!
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?