Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scala Coursera Week 6

 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you guys get for the following call?



 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is 'sentence' in that call?
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:What is 'sentence' in that call?


Sorry. It is Linux rulez
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

scala> import forcomp.Anagrams._

scala> combinations(sentenceOccurrences(List("Linux", "rulez"))).size
res0: Int = 576
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34375
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Managed to complete Week6. Heading off to Week7!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic