Code Challenge: "Hello, World"

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

35 Replies - 10200 Views - Last Post: 28 August 2014 - 04:53 AM

#16 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3360
  • View blog
  • Posts: 11,397
  • Joined: 12-December 12

Re: Code Challenge: "Hello, World"

Posted 09 January 2013 - 11:44 AM

I felt obliged to mention..

Console.WriteLine("Hello World\nHello World\nHello World\nHello World\n...");

:beta1:
Was This Post Helpful? 0
  • +
  • -

#17 plaguebearer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 23-March 11

Re: Code Challenge: "Hello, World"

Posted 21 February 2013 - 06:42 AM

View Postandrewsw, on 10 January 2013 - 03:44 AM, said:

I felt obliged to mention..

Console.WriteLine("Hello World\nHello World\nHello World\nHello World\n...");

:beta1:/>


The most simple but most tedious at the same time. I got quite the laugh out of this one.
Was This Post Helpful? 0
  • +
  • -

#18 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,009
  • Joined: 05-May 12

Re: Code Challenge: "Hello, World"

Posted 22 February 2013 - 06:45 AM

I feel that the code using 'goto' is still a loop. Otherwise this classic BASIC code would not be considered an infinite loop:
10 PRINT "HELLO, WORLD"
20 GOTO 10


Was This Post Helpful? 0
  • +
  • -

#19 haseren4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 12-April 13

Re: Code Challenge: "Hello, World"

Posted 12 April 2013 - 01:03 AM

What about:
int i = ConIn.ReadLine();
Console.WriteLine("Hello World!" * i);


Was This Post Helpful? 0
  • +
  • -

#20 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,009
  • Joined: 05-May 12

Re: Code Challenge: "Hello, World"

Posted 12 April 2013 - 06:50 PM

Which language will automatically make i copies of a string using the '*' operator?
Was This Post Helpful? 0
  • +
  • -

#21 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7645
  • View blog
  • Posts: 12,898
  • Joined: 19-March 11

Re: Code Challenge: "Hello, World"

Posted 12 April 2013 - 08:22 PM

Well, python will actually do that.

Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print 72 *"Hello world! "
Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! 
>>> 



The code in post #19 isn't python, though.
Was This Post Helpful? 1
  • +
  • -

#22 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


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

Re: Code Challenge: "Hello, World"

Posted 12 April 2013 - 10:07 PM

You sortof can do it C# or VB.net.
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine( (Ѱ)"AdamSpeight2008 " * 10);
    }
  }



Spoiler

Was This Post Helpful? 2
  • +
  • -

#23 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,009
  • Joined: 05-May 12

Re: Code Challenge: "Hello, World"

Posted 14 April 2013 - 09:13 PM

But lines 9-10 is a loop which violates the restrictions of the challenge.
Was This Post Helpful? 0
  • +
  • -

#24 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


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

Re: Code Challenge: "Hello, World"

Posted 14 April 2013 - 09:19 PM

Skydiver: Take a chill pill man. It was in response to your question on which languages have the behavior, that C# can simulate it.
Was This Post Helpful? 0
  • +
  • -

#25 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,009
  • Joined: 05-May 12

Re: Code Challenge: "Hello, World"

Posted 15 April 2013 - 06:00 AM

Yup, and I love the implementation you have to replicate the string! :)
Was This Post Helpful? 0
  • +
  • -

#26 RexGrammer  Icon User is offline

  • Coding Dynamo
  • member icon

Reputation: 181
  • View blog
  • Posts: 777
  • Joined: 27-October 11

Re: Code Challenge: "Hello, World"

Posted 14 May 2013 - 04:27 AM

@Adam
Spoiler


The author said no LINQ, and extension methods are LINQ standard query operators. I guess this wouldn't be allowed, would it?

This post has been edited by RexGrammer: 14 May 2013 - 04:27 AM

Was This Post Helpful? 0
  • +
  • -

#27 Curtis Rutland  Icon User is online

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


Reputation: 4468
  • View blog
  • Posts: 7,780
  • Joined: 08-June 10

Re: Code Challenge: "Hello, World"

Posted 14 May 2013 - 08:14 AM

The first one you did is quite interesting. The second two are just simple loops obfuscated by a function call.
Was This Post Helpful? 0
  • +
  • -

#28 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


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

Re: Code Challenge: "Hello, World"

Posted 14 May 2013 - 10:31 AM

View PostRexGrammer, on 14 May 2013 - 12:27 PM, said:

@Adam
The author said no LINQ, and extension methods are LINQ standard query operators. I guess this wouldn't be allowed, would it?


Yep LINQ uses Extension Methods, but that doesn't imply that all Extension Methods are LINQ methods. .Count could easily be a member function, especially if its a collection type.

So that leads to discuss of what constitutes a LINQ extension method?
Is that any method in the module System.Enumerable?
I could fairly easily simulate the LINQ methods using Yield using my own functions.
Would that be LINQ?
For example my version of Where
public static IEnumerable<Tin> Filter (this IEnumerable<T> ie, func<T,b> pred )
{
  var en = ie.GetEnumerator;
  while(en.MoveNext)
  {
    if( pred( en.Current ) 
    { 
      yield en.Current;
    }
   }
 } 



IEnumerable<T> which I'll shorten to IE<T>

The basic types are
     Tin -> IE<Tout> Produces an IEnumerable Range, Repeat
 IE<Tin> -> IE<Tout> Transforms an IEnumerable eg Select, Where
 IE<Tin> -> Tout     Aggregates an IEnumerable into a single result eg Aggregate, Count, Sum 
 IE<Tin> -> void     Used just for producing a side-effect eg Outputting to screen. ForEach



So my Repeat method is not a method or an overload. So I say allowed.

Let's look at ForEach not in the list, actually its a member funtion of List<T>. So I say it's allowed.

Now the .ToList which takes an IEnumerable and creates a List contain those elements.
I say it should be allowed. As it is essentially doing.
  static List<T> ToList<T>(this IE<T> seq )
  {
    return New List<T>( seq ); }
  }


All be it i in shorter form.

So I could have written it as.
 (New List<String>( Repeat("Hello World\n",10) )).ForEach(Console.WriteLine); 


I say definitly disallow any in the list that are take in an IEnumerable and return an IEnumerable.
Eg
   Select
   Where
   SelectMany
 

And any overload that that take in as a parameter a Func.
Eg
   Sum( ie , selector )
   Count( ie, predicate )
 

Was This Post Helpful? 1
  • +
  • -

#29 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Code Challenge: "Hello, World"

Posted 14 May 2013 - 11:14 PM

did I miss something?
Spoiler

This post has been edited by ishkabible: 14 May 2013 - 11:15 PM

Was This Post Helpful? 0
  • +
  • -

#30 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


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

Re: Code Challenge: "Hello, World"

Posted 14 May 2013 - 11:54 PM

ishkabible: There isn't an overload of the constructor that takes a string and an integer as parameters. The closest takes a char and an integer.
Was This Post Helpful? 0
  • +
  • -

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