Author Topic: [ENDED] Code Golf Contest #6  (Read 14833 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 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).

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
« Last Edit: June 11, 2015, 08:57:45 am by pimathbrainiac »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
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 :P
« Last Edit: August 18, 2014, 12:52:43 pm by Adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
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

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 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. :P Sorry, no more changes this time.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
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

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
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?
THEGAME
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.

Offline Runer112

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

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 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"?
Click here for the only set of games you'll ever need
= ?

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
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?
THEGAME
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.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
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 :P

Edit : ok, I did - it's much better now that I read the post carefully :D
« Last Edit: August 18, 2014, 02:37:17 pm by Adriweb »
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 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 :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
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
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)

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 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"?
Click here for the only set of games you'll ever need
= ?

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
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 »

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 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"?
Click here for the only set of games you'll ever need
= ?