Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Ten Lines or Less!

case sensitive

  • Please log in to reply
26 replies to this topic

#25 marwex89

marwex89

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 2857 posts

Posted 25 August 2009 - 11:17 AM

+rep to anyone who does the last challenge in ASM :P
  • 0
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#26 ArekBulski

ArekBulski

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 480 posts

Posted 27 August 2009 - 10:55 PM

After having a long break from coding I thought: "why not play around like during the good old times". So here is a version with Winged' requirements. As no n-dimensional array is required, only input and output is. My language is C# as always. :)

I spent quite some time on multi-dimensional arrays, but they do not work for me. If I can create an Array class then I cannot populate it. And I cannot create a multi-dimensional int[] array, only one-dimensional. I even tried to use unsafe context. :w00t:

/// This version has no n-dimensional array requirement. 
Random rand = new Random();
StreamWriter file = File.CreateText(args[0]);

/// Variable indexCount will say how many values a would-be array would contain.
int indexCount = 1;
for (int i = 1; i < args.Length; i++)
{
indexCount *= int.Parse(args[i]);
}

/// The output contains all the would-be array's values, in separete lines.
for (int i = 0; i < indexCount; i++)
{
file.WriteLine(rand.Next(1, 100));
}

/// If file won't be closed then content is lost!
file.Close();


Running it with command line "ConsoleApplication2.exe output.txt 2 3 1" will give out this output file. Dimensions 2x3x1 will give 6 elements. You can download the source and build, too. I used 8 lines of code, excluding comments and brackets. So what do you think my brothers in arms? :cool:

57
36
3
52
27
66

Attached Files


  • 0

#27 ZekeDragon

ZekeDragon

    CC Leader

  • Retired Mod
  • PipPipPipPipPipPipPip
  • 1263 posts

Posted 30 August 2009 - 04:06 PM

I can't differentiate between the arrays.

You may decide how this output looks, so long as there is a definite way to differentiate to the user which array is which.

You must do that too! :)
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?





Also tagged with one or more of these keywords: case sensitive

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download