Omnimaga

Calculator Community => Contests => Community Contests => Topic started by: JWinslow23 on August 18, 2014, 12:26:04 pm

Title: [ENDED] Code Golf Contest #6
Post by: JWinslow23 on August 18, 2014, 12:26:04 pm
Let's start fresh.

NEXT: Here (http://www.omnimaga.org/other-calculator-discussion-and-news/code-golf-contest-7)
PREVIOUS: Here (http://www.omnimaga.org/other-calculator-discussion-and-news/code-golf-contest-5)

Challenge 6

Problem
Make a program that, given an input as a number, outputs the program size as a word (i.e. SEVENTY-FIVE or ONE HUNDRED TWELVE or ONE THOUSAND ONE HUNDRED THIRTY-SEVEN), then the square of the sum of the digits of the input (separated by newlines).

Deadline
August 25, 2014, 1:00 AM EST

As each program WILL be different, no examples are given. I do expect that you understand it enough to give a decent solution.

If any further clarification is needed, contact me. I will try to reduce your sighs (size). (Bad pun, I know :P )

Ruby2
RankUserSizeDateCode
1Juju508/22/2014 9:41:36 PM
Spoiler For Spoiler:
a=0;gets.each_char{|b| a+=b.to_i};p "FIFTY";p a**2

Golfscript
RankUserSizeDateCode
1JWinslow23268/18/2014 12:23:43 PM
Spoiler For Spoiler:
"TWENTY-SIX"\n\0\{48-+}/.*

TI-83+ BASIC
RankUserSizeDateCode
1JWinslow23308/19/2014 10:25:34 AM
Spoiler For Spoiler:
ClrHome
Disp "THIRTY
.5xrootsum(int(10fPart(Ans/10^(cumSum(binomcdf(98,0

Batch
RankUserSizeDateCode
1JWinslow231298/18/2014 1:23:40 PM
Spoiler For Spoiler:
@set/an=0
@for /f "delims=" %%a in ('cmd/u/cecho %1^|find/v""')do @set/an+=%%a
@set/an*=n
@echo ONE HUNDRED TWENTY-NINE
@echo %n%

Python3
RankUserSizeDateCode
1JWinslow23598/19/2014 10:07:00 PM
Spoiler For Spoiler:
z=0
for y in input():z=z+eval(y)
print("FIFTY-NINE\n",z**2)
2willrandship628/19/2014 9:02:51 PM
Spoiler For Spoiler:
b=0
for a in input():b=b+eval(a)
print("SIXTY-TWO\n"+str(b*b))

CJam
RankUserSizeDateCode
1JWinslow23208/19/2014 10:25:34 AM
Spoiler For Spoiler:
"TWENTY"Ac+0q{~+}/_*

Axe
RankUserSizeDateCode
1JWinslow231108/19/2014 2:04:56 AM
Spoiler For Spoiler:
Ans->X
0->N
While X
^10+N->N
X/10->X
End
Disp "ONE HUNDRED TEN",i,N^^2>Dec

Perl
RankUserSizeDateCode
1willrandship688/19/2014 8:58:36 PM
Spoiler For Spoiler:
for(split//,<>){$b+=ord($_)-48;}$b+=38;$b**=2;print"SIXTY-EIGHT\n$b"

Language Ranking
RankLangUserSizeDate
1CJamJWinslow23208/19/2014 10:25:34 AM
2GolfscriptJWinslow23268/18/2014 12:23:43 PM
3TI-83+ BASICJWinslow23308/18/2014 12:23:43 PM
4Ruby2Juju508/20/2014 9:41:36 PM
5Python3JWinslow23598/19/2014 10:07:00 PM
6Perlwillrandship688/19/2014 8:58:36 PM
7AxeJWinslow231108/19/2014 2:04:56 AM
8BatchJWinslow231298/18/2014 1:23:40 PM
Title: Re: Code Golf Contest #6
Post by: Adriweb on August 18, 2014, 12:50:38 pm
There are tons all over the web in many languages, but anyway, I submitted mines (Lua and PHP) ^^

Edit : wait, you edited, so I don't have anything right now :P
Title: Re: Code Golf Contest #6
Post by: ben_g on August 18, 2014, 12:52:15 pm
I've got a 41 byte python solution. I might have a chance this time.
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 18, 2014, 12:54:54 pm
I've got a 41 byte python solution. I might have a chance this time.
For the updated challenge? Then the first thing it must output after input is "FORTY-ONE".

EDIT: I see now that you actually did the quine challenge. :P Sorry, no more changes this time.
Title: Re: Code Golf Contest #6
Post by: ben_g on August 18, 2014, 12:56:51 pm
No, this was for the old challenge. Ignore my submission PM because it's wrong then.
Title: Re: Code Golf Contest #6
Post by: Juju on August 18, 2014, 12:59:51 pm
Now it's interesting.
Title: Re: Code Golf Contest #6
Post by: Runer112 on August 18, 2014, 01:16:21 pm
Is there any particular way in which the two outputs must be separated? Can they just be mushed together like ONE HUNDRED285, or must there be a space or a newline separating them?
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 18, 2014, 01:20:54 pm
They must be newline-separated.


I have a 26-byte Golfscript already. And a 34-byte TI-BASIC.
Title: Re: Code Golf Contest #6
Post by: Juju on August 18, 2014, 01:21:41 pm
I got 54 bytes in Ruby.
Title: Re: Code Golf Contest #6
Post by: Adriweb on August 18, 2014, 01:53:52 pm
I'm eager to see how you guys made words out of numbers ( without any built-in libs, that is), in such a low number of bytes.
... or maybe I'm just missing something :P

Edit : ok, I did - it's much better now that I read the post carefully :D
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 18, 2014, 02:28:13 pm
I'm eager to see how you guys made words out of numbers ( without any builin libs, that is), in such a low number of bytes.
... or maybe I'm just missing something :P

Edit : ok, I did - it's much better now that I read the post carefully :D
It's kinda like, in TI-BASIC:
Code: [Select]
Disp "SEVENExcept you have to add the input handling I mentioned earlier. :P
Title: Re: Code Golf Contest #6
Post by: Jim Bauwens on August 19, 2014, 05:45:43 am
I have a question. I made a TI-Nspire Lua console some time ago that basically gives you a Lua command line where you can enter scripts (and it has io, etc). Am I allowed to enter scripts that run in it (and depend on it)?


(Basically it's a bit like a shell)
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 19, 2014, 10:05:41 am
I have a question. I made a TI-Nspire Lua console some time ago that basically gives you a Lua command line where you can enter scripts (and it has io, etc). Am I allowed to enter scripts that run in it (and depend on it)?


(Basically it's a bit like a shell)
If it works in a normal Nspire Lua script editor (like LDStudios has), it shall be acceptable.

Also, I have a smaller version of the TI-BASIC entry, a 60-byte Python entry, and the first Axe entry, all completed! Updating in a bit.
Title: Re: Code Golf Contest #6
Post by: Jim Bauwens on August 19, 2014, 12:58:48 pm
Well basically, it would be a script you enter in a console like this:

(http://www.ticalc.org/archives/files/ss/849/84921.gif)

It's just a different environment (that anyone can use).


Edit: in a sense I suppose you can not keep this in the same category as Nspire-Lua, considering the difference.
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 19, 2014, 01:02:41 pm
I can accept that. Just don't use any environment-specific features, if possible (i.e. make it so others can also run it in a different environment).
Title: Re: Code Golf Contest #6
Post by: Jim Bauwens on August 19, 2014, 01:10:49 pm
Well the thing would be, you can't really use a console if the other environment doesn't provide one :P
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 19, 2014, 01:12:51 pm
Well the thing would be, you can't really use a console if the other environment doesn't provide one :P
I'll accept it if anyone with an Nspire can run it with as few external utilities as possible. The tester I use is http://bwns.be/jim/WEBspire/editor.html
Title: Re: Code Golf Contest #6
Post by: Jim Bauwens on August 19, 2014, 01:20:22 pm
Okay, I didn't add image support to that yet (the tester) so I suppose it will not work. Anyway, I'll see.
Title: Re: Code Golf Contest #6
Post by: Adriweb on August 19, 2014, 01:24:21 pm
probably a TINCS screenshot can act as a proof if needed ^^
Title: Re: Code Golf Contest #6
Post by: JWinslow23 on August 25, 2014, 04:25:27 pm
Contest over.