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

0 Members and 1 Guest are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
[ENDED] Code Golf - The Reboot #5
« on: June 29, 2015, 03:47:53 pm »
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: [Select]
N = 14
D = 2

1 + 4 = 5
4 + 5 = 9
5 + 9 = 14
197 is a Keith Number:
Code: [Select]
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: [Select]
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
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
RankUserSizeDate
1@lirtosiast43Jul 01 2015 02:25:25 pm
2@PT_43Jul 02 2015 01:24:20 pm
3@mr womp womp97Jun 30 2015 09:13:00 pm

Lua
RankUserSizeDate
1@Adriweb152Jun 30 2015 02:06:20 am

Javascript
RankUserSizeDate
1@Adriweb112Jun 30 2015 02:06:20 am

Java
RankUserSizeDate
1@c4ooo190Jul 01 2015 12:32:49 pm

Ruby
RankUserSizeDate
1@Juju150Jun 30 2015 04:57:53 pm

Python
RankUserSizeDate
1@Cumred_Snektron83Jul 01 2015 10:37:07 am

Language Ranking
RankLangUserSizeDate
1TI-BASIC@lirtosiast43Jul 01 2015 02:25:25 pm
2Python@Cumred_Snektron83Jul 01 2015 10:37:07 am
3Javascript@Adriweb112Jun 30 2015 02:06:20 am
4Ruby@Juju150Jun 30 2015 04:57:53 pm
5Lua@Adriweb152Jun 30 2015 02:06:20 am
6Java@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.
« Last Edit: July 05, 2015, 02:13:37 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline c4ooo

  • Project Author
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
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 :D
-German Kuznetsov
The impossible chemical compound.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
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 :D
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"?
Click here for the only set of games you'll ever need
= ?

Offline c4ooo

  • Project Author
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
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 :D
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 :P
 
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.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
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 :D
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 :P
 
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 :P
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline c4ooo

  • Project Author
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Code Golf - The Reboot #5
« Reply #5 on: June 29, 2015, 10:04:29 pm »
Entry submitted, 217 bytes in java. 8) ;D
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.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
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 »

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
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-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf - The Reboot #5
« Reply #8 on: June 30, 2015, 11:31:12 pm »
Entry submitted, 217 bytes in java. 8) ;D
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"?
Click here for the only set of games you'll ever need
= ?

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
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"?
Click here for the only set of games you'll ever need
= ?

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
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?

Offline c4ooo

  • Project Author
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
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 :P
-German Kuznetsov
The impossible chemical compound.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
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"?
Click here for the only set of games you'll ever need
= ?

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
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"?
Click here for the only set of games you'll ever need
= ?

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
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! :D
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?