File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Scala and the fly likes Scala Coursera Week 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "Scala Coursera Week 6" Watch "Scala Coursera Week 6" New topic
Author

Scala Coursera Week 6

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

What do you guys get for the following call?




SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

What is 'sentence' in that call?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Jesper de Jong wrote:What is 'sentence' in that call?


Sorry. It is Linux rulez
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16


scala> import forcomp.Anagrams._

scala> combinations(sentenceOccurrences(List("Linux", "rulez"))).size
res0: Int = 576
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4344
    
    8

I haven't got my Scala set up with me, so I can't run it. And I may be missing something obvious. But doing the maths, shouldn't it be 2x2x2x2x2x2x3x3 = 576?

Edit: which means I agree with Jesper.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Jesper de Jong wrote:
scala> import forcomp.Anagrams._

scala> combinations(sentenceOccurrences(List("Linux", "rulez"))).size
res0: Int = 576


I guess I have to rework my combinations method which is the bloody culprit in my case. No wonder why it would run into OutOfMemoryError in my case.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30146
    
150

Aghh! I wasted two hours yesterday mixing up :: and :::. Which caused me to go all the way into left field finishing this up.

This assignment was so much harder than the previous one. Could have used the two weeks here and not there.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Managed to complete Week6. Heading off to Week7!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Scala Coursera Week 6