• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Subset of Cubes

 
buckaroo
Posts: 401
Postgres Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Write an algorithm, using pseudo code, to perform one of the following tasks, and post it to the class folder by day 4. Then, choose one algorithm that was created and posted by another student to solve the same problem, and analyze the differences between the effectiveness of the two algorithms. Post the result of the analysis, and improvements to your algorithm by day 6 of the seminar. Be creative, and have fun!
Given a string of numbers, identify all of the substrings that form numbers that are divisible by 3. For example, applying the algorithm on the string 37540 should produce the following substrings (not necessarily in this order): 0; 3; 75; 54; 375; 540



I was pm'd about this this morning. While I have not been involved in the cattle drive for some time now, I have become intrigued with this assignment and have a question about what is expected in the nit picking. The expected results in any order is { 0, 3, 75, 54, 375, 540 }, but if

identify all of the substrings that form numbers that are divisible by 3

is the goal then what about 30, 45, 57, 453, etc? Or is it not 'any combonation' given the set { 3, 7, 5, 4, 0 }?
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's an interesting assignment - but I don't think it hails from the cattle drive.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given a string of numbers, identify all of the substrings that form numbers that are divisible by 3. For example, applying the algorithm on the string 37540 should produce the following substrings (not necessarily in this order): 0; 3; 75; 54; 375; 540

... what about 30, 45, 57, 453, etc? Or is it not 'any combination' given the set { 3, 7, 5, 4, 0 }?


I would say that the numbers need to be next to each other. Since it sounds to me like you are limited to one substring, you can't leave numbers out of the middle of "37540" to get "30". The only way to do that would be to concatenate two substrings. "3" + "0".
 
Donald R. Cossitt
buckaroo
Posts: 401
Postgres Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marilyn. And it would be an "interesting assignment" to do it both ways
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic