Challenge: L-R Parse?

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 8972 Views - Last Post: 21 July 2014 - 05:20 PM

#16 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1390
  • View blog
  • Posts: 3,075
  • Joined: 05-April 11

Re: Challenge: L-R Parse?

Posted 14 June 2014 - 09:28 AM

Quote

Rolled a little more verbose, and rules complex, than most folk (or so it seems on passing inspection)

I might have beaten you with some even more complex code modi123_1 :D

It bothers me the challenge is easy - moderate
I've found the challenge quite difficult and complex haha
Maybe it's because I added decimal to the mix... I don't know

The test cases being used
Spoiler


I added decimal functionality as well
Spoiler


The equivalent Java code
Spoiler


Is it really true that you cannot initialize an anonymous type like this in VB.NET?
Seems like it won't let me implement methods, but only define properties
Makes me sad, I really like it :(
		IInternalValidator validator = new IInternalValidator() {
			public boolean validate(String number, int index) {
				return false;
			}
		};


This post has been edited by CasiOo: 14 June 2014 - 09:31 AM

Was This Post Helpful? 0
  • +
  • -

#17 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2251
  • View blog
  • Posts: 9,435
  • Joined: 29-May 08

Re: Challenge: L-R Parse?

Posted 15 June 2014 - 08:30 AM

Quote

It bothers me the challenge is easy - moderate
I've found the challenge quite difficult and complex haha


I reckon it easy - moderate as it doesn't require much more that a single loop and a couple of variable of state. Plus a bit of thinking about the algorithm.

And doesn't involve any advanced concepts like RegEx \d{1,3}(\,\d{3})*.

This post has been edited by AdamSpeight2008: 15 June 2014 - 08:31 AM

Was This Post Helpful? 0
  • +
  • -

#18 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Challenge: L-R Parse?

Posted 16 June 2014 - 06:35 AM

Thought I'd give the decimal point a shot. I've been learning python so here's a python solution:

You can put if x: return false on one line in python but it's considered bad style by the Python community. This would be a bit shorter if I rewrote it in VB/java.

I'm not happy with this solution. I don't think it is very clear.

Spoiler

This post has been edited by cfoley: 16 June 2014 - 06:35 AM

Was This Post Helpful? 0
  • +
  • -

#19 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Challenge: L-R Parse?

Posted 16 June 2014 - 09:12 AM

Happier with this one:

Spoiler

Was This Post Helpful? 0
  • +
  • -

#20 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2251
  • View blog
  • Posts: 9,435
  • Joined: 29-May 08

Re: Challenge: L-R Parse?

Posted 18 June 2014 - 12:09 PM

My entry with decimal point numbers.
Spoiler

This post has been edited by AdamSpeight2008: 18 June 2014 - 12:41 PM

Was This Post Helpful? 0
  • +
  • -

#21 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: Challenge: L-R Parse?

Posted 18 June 2014 - 07:18 PM

Quote

This challenge is open to all languages

Great, here is my take using NASM on Linux and using the x64 instruction set...

Spoiler


I could cram all of the checking into one loop, but this was easier for my brain.
Was This Post Helpful? 0
  • +
  • -

#22 IronRazer  Icon User is offline

  • D.I.C Addict

Reputation: 236
  • View blog
  • Posts: 778
  • Joined: 01-February 13

Re: Challenge: L-R Parse?

Posted 21 July 2014 - 05:20 PM

Well, i know it is pretty late but, just saw this and was bored so here is my short and simple take on it. I didn`t iterate left to right character by character so to say but, it does check from left to right, its just that i check groups of characters from left to right with 7 LOC. -.-

    Public Function Valid(ByVal text As String) As Boolean
        Dim ss() As String = text.Split(CChar(","))
        For x As Integer = 0 To ss(x).Length - 1
            If ss(x).Length > 3 Or (ss(x).Length < 3 And Not x = 0) Or (ss.Length = 0 And x = 0) Then Return False
        Next
        Return True
    End Function



EDIT : Forgot to add (x). :whistling:

This post has been edited by IronRazer: 22 July 2014 - 08:44 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2