CodeWalrus

Development => Calculators => Calculator News, Coding, Help & Talk => Topic started by: JWinslow23 on June 29, 2015, 07:50:18 PM

Title: [ENDED] Code Golf - The Reboot #5
Post by: JWinslow23 on June 29, 2015, 07:50:18 PM
Everybody back off, I'm taking back this contest :walrii:

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. (https://www.omnimaga.org/community-contests/code-golf-contest-1/) 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 (https://www.omnimaga.org/community-contests/code-golf-the-reboot-1/) OR this really old contest thread (https://www.omnimaga.org/community-contests/code-golf-contest-1/) 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:N = 14
D = 2

1 + 4 = 5
4 + 5 = 9
5 + 9 = 14
197 is a Keith Number: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: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 (http://juju2143.ca/golf/).
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 (http://pastebin.com/iEQkmzcP).
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on June 29, 2015, 11:16:03 PM
Ummm Are the dates wrong? 1970? Is there some reason that is?
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on June 29, 2015, 11:55:36 PM
Quote from: Unicorn on June 29, 2015, 11:16:03 PM
Ummm Are the dates wrong? 1970? Is there some reason that is?
Nobody has submitted an entry yet. That's the Unix epoch :P
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on June 30, 2015, 01:24:08 AM
Ah... So I don't quit get it, As the result I have to make it display the whole tree, or just the final answer?
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on June 30, 2015, 05:16:52 AM
Quote from: Unicorn on June 30, 2015, 01:24:08 AM
Ah... So I don't quit get it, As the result I have to make it display the whole tree, or just the final answer?
As a result, you just need to tell me if the input N is a Keith number. The code tags are just so you know how such determination works. Output may be anything, but it must be different for true and false. And you must specify what means true or false.
Title: Re: Code Golf - The Reboot #5
Post by: Adriweb on June 30, 2015, 07:15:05 AM
Lua, 152
JS, 112.
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on July 01, 2015, 03:59:39 AM
Updated!
Title: Re: Code Golf - The Reboot #5
Post by: Dream of Omnimaga on July 01, 2015, 04:02:22 AM
Gode move to cross-post this I think. It will get more participants :)
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on July 01, 2015, 10:02:39 AM
Indeed, also, ti basic is winning! :D
Title: Re: Code Golf - The Reboot #5
Post by: Duke "Tape" Eiyeron on July 01, 2015, 10:10:51 AM
TI-Basic helps because "DispGraph" is not 9 bytes but one because it's actually a token. Do TI-89 basic and it'll be heavier, probably.
Title: Re: Code Golf - The Reboot #5
Post by: Snektron on July 01, 2015, 03:39:19 PM
Quote from: Unicorn on July 01, 2015, 10:02:39 AM
Indeed, also, ti basic is winning! :D
HISS HISS MOTHERF :walrii:
83 bytes, Python.
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on July 01, 2015, 04:45:02 PM
Quote from: DJ Omnimaga on July 01, 2015, 04:02:22 AM
Gode move to cross-post this I think. It will get more participants :)
Yeah, thanks. That's my thought process too.
Quote from: Cumred_Snektron on July 01, 2015, 03:39:19 PM
Quote from: Unicorn on July 01, 2015, 10:02:39 AM
Indeed, also, ti basic is winning! :D
HISS HISS MOTHERF :walrii:
83 bytes, Python.
I would just like to point out, some of these languages may not have optimal solutions (I know for a fact that TI-BASIC could be cut down a lot). You can challenge those if you'd like; that's really what Code Golf is all about. :walrii:

On an unrelated note, I wonder if anybody will be able to send their code to my girlfriend :P
Title: Re: Code Golf - The Reboot #5
Post by: Snektron on July 01, 2015, 04:46:02 PM
I don't even know her name. Tracking down random people on the Inetz? :P
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on July 01, 2015, 05:25:55 PM
Quote from: Cumred_Snektron on July 01, 2015, 04:46:02 PM
I don't even know her name. Tracking down random people on the Inetz? :P
That's the point. To make people try to no avail to be the one to get a bonus. I think it's possible, but very hard.
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on July 01, 2015, 07:08:25 PM
Do a facial recognition search. Unless that picture is of someone else? O.O
Title: Re: Code Golf - The Reboot #5
Post by: Dream of Omnimaga on July 01, 2015, 08:33:53 PM
Quote from: Duke "Tape" Eiyeron on July 01, 2015, 10:10:51 AM
TI-Basic helps because "DispGraph" is not 9 bytes but one because it's actually a token. Do TI-89 basic and it'll be heavier, probably.
Doesn't 89 BASIC get smaller when tokenized, though? I know it's still larger than 83+ BASIC no matter what, but I thought that once the program was ran that it was smaller.
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on July 01, 2015, 09:50:11 PM
Just got a 43 byte entry by @lirtosiast which uses no error/ERR:OVERFLOW as true/false . Clever code, @lirtosiast ! As to the others, keep up the good work!
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on July 02, 2015, 06:16:50 PM
geez, lirto's the master O.O
Title: Re: Code Golf - The Reboot #5
Post by: alexgt on July 02, 2015, 06:32:42 PM
Quote from: JWinslow23 on July 01, 2015, 05:25:55 PM
Quote from: Cumred_Snektron on July 01, 2015, 04:46:02 PM
I don't even know her name. Tracking down random people on the Inetz? :P
That's the point. To make people try to no avail to be the one to get a bonus. I think it's possible, but very hard.
But it says  "-90%" negative?
Title: Re: Code Golf - The Reboot #5
Post by: Snektron on July 02, 2015, 06:45:11 PM
It means (total amount) - 0.9*(total amount) = new amount
Title: Re: Code Golf - The Reboot #5
Post by: JWinslow23 on July 02, 2015, 07:04:30 PM
Quote from: Cumred_Snektron on July 02, 2015, 06:45:11 PM
It means (total amount) - 0.9*(total amount) = new amount
That's why I said bonus instead of deduction...some people forget that in code golf, lowest score wins :P
Title: Re: Code Golf - The Reboot #5
Post by: alexgt on July 02, 2015, 07:34:07 PM
Oh... that makes more sense :P
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on July 02, 2015, 09:04:12 PM
Ah,  I was wondering about that too :P
Title: Re: [ENDED] Code Golf - The Reboot #5
Post by: JWinslow23 on July 05, 2015, 06:15:46 PM
The contest is over! I hope everybody had fun with this challenge! :D
Title: Re: Code Golf - The Reboot #5
Post by: Dream of Omnimaga on July 06, 2015, 02:17:10 AM
Congrats to the winner :D and good job everyone :)
Title: Re: [ENDED] Code Golf - The Reboot #5
Post by: JWinslow23 on July 06, 2015, 05:01:06 PM
And yes, Unicorn. My profile pic has my girlfriend in it. Your new Code Golf challenge is to find her :P jk
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on July 06, 2015, 10:03:28 PM
Probably the closest I could come to winning this one :P
Title: Re: [ENDED] Code Golf - The Reboot #5
Post by: alexgt on July 07, 2015, 03:40:23 PM
Quote from: JWinslow23 on July 06, 2015, 05:01:06 PM
And yes, Unicorn. My profile pic has my girlfriend in it. Your new Code Golf challenge is to find her :P jk
And that is why I am making an artificial intelligence system :P
The hunt begins...
Title: Re: Code Golf - The Reboot #5
Post by: Unicorn on July 08, 2015, 01:49:32 AM
Wait, your AI  could find her? O.O :P