• [ENDED] Code Golf Contest #6 5 2
Currently:

### Author Topic: [ENDED] Code Golf Contest #6  (Read 7875 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 Contest #6
« on: August 18, 2014, 12:26:04 pm »
Let's start fresh.

NEXT: Here
PREVIOUS: Here

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).

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 )

Ruby2
 Rank User Size Date Code 1 Juju 50 8/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
 Rank User Size Date Code 1 JWinslow23 26 8/18/2014 12:23:43 PM Spoiler For Spoiler: "TWENTY-SIX"\n\0\{48-+}/.*

TI-83+ BASIC
 Rank User Size Date Code 1 JWinslow23 30 8/19/2014 10:25:34 AM Spoiler For Spoiler: ClrHomeDisp "THIRTY.5xrootsum(int(10fPart(Ans/10^(cumSum(binomcdf(98,0

Batch
 Rank User Size Date Code 1 JWinslow23 129 8/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
 Rank User Size Date Code 1 JWinslow23 59 8/19/2014 10:07:00 PM Spoiler For Spoiler: z=0for y in input():z=z+eval(y)print("FIFTY-NINE\n",z**2) 2 willrandship 62 8/19/2014 9:02:51 PM Spoiler For Spoiler: b=0for a in input():b=b+eval(a)print("SIXTY-TWO\n"+str(b*b))

CJam
 Rank User Size Date Code 1 JWinslow23 20 8/19/2014 10:25:34 AM Spoiler For Spoiler: "TWENTY"Ac+0q{~+}/_*

Axe
 Rank User Size Date Code 1 JWinslow23 110 8/19/2014 2:04:56 AM Spoiler For Spoiler: Ans->X0->NWhile X^10+N->NX/10->XEndDisp "ONE HUNDRED TEN",i,N^^2>Dec

Perl
 Rank User Size Date Code 1 willrandship 68 8/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
 Rank Lang User Size Date 1 CJam JWinslow23 20 8/19/2014 10:25:34 AM 2 Golfscript JWinslow23 26 8/18/2014 12:23:43 PM 3 TI-83+ BASIC JWinslow23 30 8/18/2014 12:23:43 PM 4 Ruby2 Juju 50 8/20/2014 9:41:36 PM 5 Python3 JWinslow23 59 8/19/2014 10:07:00 PM 6 Perl willrandship 68 8/19/2014 8:58:36 PM 7 Axe JWinslow23 110 8/19/2014 2:04:56 AM 8 Batch JWinslow23 129 8/18/2014 1:23:40 PM
« Last Edit: June 11, 2015, 08:57:45 am by pimathbrainiac »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

• Editor
• LV10 31337 u53r (Next: 2000)
• Posts: 1708
• Rating: +229/-17
##### Re: Code Golf Contest #6
« Reply #1 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
« Last Edit: August 18, 2014, 12:52:43 pm by Adriweb »
My calculator programs
TI-Nspire Lua programming : Tutorials  |  API Documentation

#### ben_g

• Hey cool I can set a custom title now :)
• LV9 Veteran (Next: 1337)
• Posts: 1002
• Rating: +125/-4
• Asm noob
##### Re: Code Golf Contest #6
« Reply #2 on: August 18, 2014, 12:52:15 pm »
I've got a 41 byte python solution. I might have a chance this time.
My projects
- The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
- Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
- An android version of oxo (java)  ACTIVE
- A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
- A java MORPG. (pc) DEEP COMA(read more)(screenshot)
- a minecraft game in axe DEAD (source code available)
- a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

#### 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 Contest #6
« Reply #3 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. Sorry, no more changes this time.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### ben_g

• Hey cool I can set a custom title now :)
• LV9 Veteran (Next: 1337)
• Posts: 1002
• Rating: +125/-4
• Asm noob
##### Re: Code Golf Contest #6
« Reply #4 on: August 18, 2014, 12:56:51 pm »
No, this was for the old challenge. Ignore my submission PM because it's wrong then.
My projects
- The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
- Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
- An android version of oxo (java)  ACTIVE
- A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
- A java MORPG. (pc) DEEP COMA(read more)(screenshot)
- a minecraft game in axe DEAD (source code available)
- a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

#### Juju

• Incredibly sexy mare
• Coder Of Tomorrow
• LV13 Extreme Addict (Next: 9001)
• Posts: 5730
• Rating: +500/-19
• Weird programmer
##### Re: Code Golf Contest #6
« Reply #5 on: August 18, 2014, 12:59:51 pm »
Now it's interesting.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?

This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

#### Runer112

• Moderator
• LV11 Super Veteran (Next: 3000)
• Posts: 2289
• Rating: +639/-31
##### Re: Code Golf Contest #6
« Reply #6 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?

#### 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 Contest #6
« Reply #7 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.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Juju

• Incredibly sexy mare
• Coder Of Tomorrow
• LV13 Extreme Addict (Next: 9001)
• Posts: 5730
• Rating: +500/-19
• Weird programmer
##### Re: Code Golf Contest #6
« Reply #8 on: August 18, 2014, 01:21:41 pm »
I got 54 bytes in Ruby.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?

This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

• Editor
• LV10 31337 u53r (Next: 2000)
• Posts: 1708
• Rating: +229/-17
##### Re: Code Golf Contest #6
« Reply #9 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

Edit : ok, I did - it's much better now that I read the post carefully
« Last Edit: August 18, 2014, 02:37:17 pm by Adriweb »
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 Contest #6
« Reply #10 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

Edit : ok, I did - it's much better now that I read the post carefully
It's kinda like, in TI-BASIC:
Code: [Select]
Disp "SEVENExcept you have to add the input handling I mentioned earlier.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Jim Bauwens

• Lua! Nspire! Linux!
• Editor
• LV10 31337 u53r (Next: 2000)
• Posts: 1881
• Rating: +206/-7
• Linux!
##### Re: Code Golf Contest #6
« Reply #11 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)

#### 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 Contest #6
« Reply #12 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.
« Last Edit: August 19, 2014, 10:33:09 am by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Jim Bauwens

• Lua! Nspire! Linux!
• Editor
• LV10 31337 u53r (Next: 2000)
• Posts: 1881
• Rating: +206/-7
• Linux!
##### Re: Code Golf Contest #6
« Reply #13 on: August 19, 2014, 12:58:48 pm »
Well basically, it would be a script you enter in a console like this:

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.
« Last Edit: August 19, 2014, 01:01:37 pm by Jim Bauwens »

#### 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 Contest #6
« Reply #14 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).
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?