Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:43+00:00 2026-06-15T08:06:43+00:00

I am using VB.net 2012 and am wanting to do the following in code:

  • 0

I am using VB.net 2012 and am wanting to do the following in code:

I have a list of media items that is of length x.
Each item in the list has a duration of y.
I am wanting to create a new random list that has a total duration of z, and the items can only appear once in this new list.

What is the best way to do this? I am not sure if this qualifies as a ‘rucksack problem.’ Either way, may I please have some help to achieve this, either with pseudo code or actual vb.net code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:06:44+00:00Added an answer on June 15, 2026 at 8:06 am

    Pseudocode:

    1. Object Song: properties Name, Duration
    2. mlstLibrary = List(Of Song) ... fill mlstLibrary
    3. user enters desired playlist duration intPlaylistDuration    
    4. make a copy of mlstLibrary called mlstLibraryWorking
    5. Dim intPlaylistDurationWorking As Integer = 0
    6. Dim lstPlaylist As New List(Of Song) ' This is the output playlist
    7. Do While mlstLibraryWorking.Count > 0
    7a.  Go through mlstLibraryWorking and remove all items that have .Duration > (intPlaylistDuration - intPlaylistDurationWorking)
    7b1.  Pick random Song from mlstLibraryWorking 
    7b2.  Add selected Song to mlstPlaylist
    7b3.  intPlaylistDurationWorking += selected Song.Duration
    7b4.  Remove selected Song from mlstLibraryWorking  
    8. Loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using .NET to generate a JSON file that has many Date s in
I have just installed Android SDK on my Ubuntu Device following this example: http://www.liberiangeek.net/2012/07/download-and-install-androidsdk-in-ubuntu-12-04-precise-pangolin/
Morning all, Using C# .NET 4.0 and Visual Studio 2012 Express. I have a
I am modifying some CSS code that I got from http://tympanus.net/codrops/2012/03/15/parallax-content-slider-with-css3-and-jquery/ . It is
I have an MS Dynamics AX 2012 project and I am using .Net interop.
Im using twitter-bootstrap in my rails app i was following this tutorial : http://untame.net/2012/08/twitter-bootstrap-build-a-stunning-two-column-blog/
using .NET 3.5. I have a function I want to make multithreaded calls to.
I want to print GET/POST http headers like following on Console using net/http. GET
All, We are using ASP.NET Web API where we have a REST based service
I have a simple web service I have created. I'm using Visual Studio 2012

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.