Open Language Code Golf: RATS!

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

39 Replies - 8676 Views - Last Post: 04 October 2012 - 07:15 AM Rate Topic: -----

#31 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: Open Language Code Golf: RATS!

Posted 23 September 2012 - 08:52 PM

I don't know if the output is correct since I only validated up to 's given output but here it is in all its 277 characters glory:
Spoiler


Output:
>>> RATS(59,5)
[145, 668, 1345, 6677, 13444]



Did I get it correct? Will probably tune it to use some of Python's powerful tool kit.
Was This Post Helpful? 1
  • +
  • -

#32 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: Open Language Code Golf: RATS!

Posted 23 September 2012 - 10:23 PM

Quick question:

print 'RATS stands for Reverse, Add, {0} and Sort right?'.format(whatIsTheT)


Take a seed? ^^
Was This Post Helpful? 0
  • +
  • -

#33 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4463
  • View blog
  • Posts: 7,777
  • Joined: 08-June 10

Re: Open Language Code Golf: RATS!

Posted 24 September 2012 - 12:11 AM

Well, here's my poor attempt in C# (done while waiting for a deployment to finish at work):

static IEnumerable<int> Rats(int s, int n)
{
    for(var i=0; i<n; i++)
    {
        s = int.Parse(new string((int.Parse(new string(s.ToString().Reverse().ToArray())) + s).ToString().OrderBy(x => x).ToArray()));
        yield return s;
    }
}




Strikingly similar to some of Adam's VB.NET code, but clocks in at a heavy 160 chars not counting function declaration. I'll never be a VB.NET coder, but I may start rethinking my preconceived notions about VB.NET wordiness, considering I came up with the same solution you did, and yours is smaller.

Edit: looking again, it's pretty much identical to Adam's first entry, but I swear I didn't cheat :P
Was This Post Helpful? 1
  • +
  • -

#34 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2255
  • View blog
  • Posts: 9,444
  • Joined: 29-May 08

Re: Open Language Code Golf: RATS!

Posted 24 September 2012 - 08:38 AM

In VB.net you can drop the braces around empty method parameters, which helps a lot. As well as the lack of having to include return in the Yield statement. It's a shame that Yield isn't an expression, so you could do a yield and pass the value into an assignment / expression.
S = Yield S...blah.blah.erc


Was This Post Helpful? 0
  • +
  • -

#35 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,163
  • Joined: 08-January 12

Re: Open Language Code Golf: RATS!

Posted 03 October 2012 - 09:47 AM

Well, a quick question - why not create a separate forum for challenges? I mean, it is difficult enough to monitor challenges in C/C++/C# forum, and now I see challenges are being posted here. Just how many forums must a man see for a decent challenge? All in favor, say so. All those not in favor, go to hell.
Was This Post Helpful? 1
  • +
  • -

#36 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4463
  • View blog
  • Posts: 7,777
  • Joined: 08-June 10

Re: Open Language Code Golf: RATS!

Posted 03 October 2012 - 10:11 AM

You can bring it up in the Site Feedback forum, but it won't happen. We usually have language-specific challenges. Sometimes the creators will allow for people to enter code from other languages, and sometimes others will do it even if not asked, but the challenge should be made in the language forum that it's originally intended for.
Was This Post Helpful? 0
  • +
  • -

#37 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,163
  • Joined: 08-January 12

Re: Open Language Code Golf: RATS!

Posted 03 October 2012 - 10:14 AM

Well, I know that in C/++ challenges, all languages are more or less welcome. So, I think this should be done. I will wait for some more suggestions, and then maybe post it in that forum :)


Wait, you are a mod! So maybe you can do this.. Please? :cry2:

This post has been edited by aresh: 03 October 2012 - 10:14 AM

Was This Post Helpful? 0
  • +
  • -

#38 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4463
  • View blog
  • Posts: 7,777
  • Joined: 08-June 10

Re: Open Language Code Golf: RATS!

Posted 03 October 2012 - 01:15 PM

Mods don't have that ability. I'm not even sure the admins can add another forum. I believe that only Chris can do that. However, even if I could, I don't agree with your suggestion, as I noted in my previous post. Just because the challenge accepts other languages doesn't mean that it doesn't start as a challenge in a particular language. However, if the challenge is good, it should be featured on the front page, so check there every so often.
Was This Post Helpful? 0
  • +
  • -

#39 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2255
  • View blog
  • Posts: 9,444
  • Joined: 29-May 08

Re: Open Language Code Golf: RATS!

Posted 03 October 2012 - 01:29 PM

Challenges are often pinned topics, so check at the topic language forums.
In the vb.net challenges, submissions in vb.net are preferred and are first in line to get awards.

Take my submissions in this challenge, yeah the first couple of them are vb.net (cos that's my natural comfortable language.) Then I ventured in Python-land.

It did take us on a interesting discussion about a feature of Python, leading to the Simown constraint.

This post has been edited by AdamSpeight2008: 03 October 2012 - 01:38 PM

Was This Post Helpful? 0
  • +
  • -

#40 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Open Language Code Golf: RATS!

Posted 04 October 2012 - 07:15 AM

Technically this is a Python challenge, but I learned from my earlier challenges that making it open language yields a much better response. Also, these sorts of challenges can help spread Python's popularity by highlighting some of its strengths. In this case, the simplicity of its syntax can yield very small code :wink:

CASE AND POINT:
AdamSpeight2008 saw other people's Python code and got a great idea of his own and installed Python to test it. :D

This post has been edited by atraub: 04 October 2012 - 07:19 AM

Was This Post Helpful? 1
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3