6 Replies - 8002 Views - Last Post: 06 November 2014 - 02:14 PM

#1 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Challenge: Longest Bit Sequence

Post icon  Posted 06 July 2013 - 10:28 AM

Challenge: Longest Bit Sequence

Challenge

Write a method that returns the size and position of the longest bit sequence.

Examples
X := 00000000 00000000 00000000 01111100

size:= 5
 pos:= 2

X:=  00000000 00001000 01110100 10001100

size:= 3
 pos:= 12

X:=  01010101 01010101 01010101 01010101
size:=1
 pos:=0 



Edit: Return the right most position, in cases where multiple equal length bit sequences.

Entrants
  • Frameworks required.
  • vb.net submissions are preferred.
  • SourceCode must be in spoilered code tags.
    Spoiler

    If you don't want to reveal your code, then don't submit a submission.
  • If you like you can include a Zip-File of the project / executable.

This post has been edited by AdamSpeight2008: 06 July 2013 - 01:08 PM
Reason for edit:: Updating and correcting wording of challenge.


Is This A Good Question/Topic? 1
  • +

Replies To: Challenge: Longest Bit Sequence

#2 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Challenge: Longest Bit Sequence

Posted 07 July 2013 - 01:01 PM

What is the input datatype? Integer, String, Byte array?
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: Longest Bit Sequence

Posted 07 July 2013 - 02:03 PM

It's open to interpretation, I only specified write a method, not what the method parameter(s).

For mine I'm using Int32 for mine and returning an array of Int32 (containing 2 entries, 1st is size, 2nd is position)

Spoiler

This post has been edited by AdamSpeight2008: 07 July 2013 - 02:50 PM

Was This Post Helpful? 0
  • +
  • -

#4 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Challenge: Longest Bit Sequence

Posted 08 July 2013 - 02:34 AM

OK, well since the input type isn't specified, I'll assume that it is subject to change and define a BitSequence interface. The function has to return 2 values so what is really needed is a class to hold them. I believe the way to write methods that act on interfaces in VB.NET is extension methods.

Here is my solution:

Spoiler


Here is some extra code to make it work, including an implemntation of BitSequence:

Spoiler

Was This Post Helpful? 1
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: Challenge: Longest Bit Sequence

Posted 08 July 2013 - 07:21 AM

cfoley: Nice linear algorithm O(n), came up with a similar on last night.
Was This Post Helpful? 0
  • +
  • -

#6 dbasnett  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 609
  • Joined: 01-October 08

Re: Challenge: Longest Bit Sequence

Posted 06 November 2014 - 02:11 PM

Don't know spoiler tags...
Spoiler

This post has been edited by GunnerInc: 06 November 2014 - 02:52 PM
Reason for edit:: added spoiler tags

Was This Post Helpful? 0
  • +
  • -

#7 ybadragon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 297
  • View blog
  • Posts: 1,525
  • Joined: 11-May 12

Re: Challenge: Longest Bit Sequence

Posted 06 November 2014 - 02:14 PM

@dbasnett [spoiler][/spoiler]

This post has been edited by ybadragon: 06 November 2014 - 02:14 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1