Looking for an inspiration? Below you will find public programs submitted by other users.

Filter by: All Bash C C# C++ 4.8.1 C++11 Haskell Java Java7 Objective-C Pascal (fpc) Pascal (gpc) Perl PHP Python Python 3 Ruby SQL VB.NET Ada Assembler Assembler AWK (gawk) AWK (mawk) bc Brainf**k C++ 4.3.2 C99 strict CLIPS Clojure COBOL COBOL 85 Common Lisp (clisp) D (dmd) Erlang F# Factor Falcon Forth Fortran Go Groovy Icon Intercal JavaScript (rhino) JavaScript (spidermonkey) Lua Nemerle Nice Nimrod Node.js Ocaml Octave Oz PARI/GP Perl 6 Pike Prolog (gnu) Prolog (swi) R Scala Scheme (guile) Smalltalk Tcl Text Unlambda Whitespace

#YT45Yu Scala 41 minutes ago
Success
  1. // CLASS RATIONAL (for fractions)
  2.  
  3. object Main extends App {
  4. class Rational(n: Int, d:Int){
  5. require(d != 0)
  6. val numer:Int = n
  7. val denom:Int = d
  8. override def toString = numer + "/" + denom
  9. def +(that:Rational):Rational =
#9Obhvz Scala 3 hours ago
Compilation error
  1. object ContigiousNumber {
  2.  
  3.  
  4. //Scala Proejct will start from main
  5. def main(args: Array[String]){
  6. println(getLongestLists(getPossibleSequenceLists(List(19,3,11,7,15,12,4,12,8,16))));
  7.  
  8.  
  9. }
#8NvBUV Scala 3 hours ago
Compilation error
  1. object ContigiousNumber {
  2.  
  3.  
  4. //Scala Proejct will start from main
  5. def main(args: Array[String]){
  6. println(getLongestLists(getPossibleSequenceLists(List(19,3,11,7,15,12,4,12,8,16))));
  7.  
  8.  
  9. }
#SdxKwV Scala 3 hours ago
Compilation error
  1. object Main extends App {
  2. def div(a: Int, b: Int) = {
  3. def inneDiv(acc,a,b) : (Int, Int) = {
  4. (3,3)
  5. }
  6. innerDiv(0,a,b)
  7. }
  8. // your code goes here
  9. println(div(6,2))
#tfvKUR Scala 9 hours ago
Compilation error
  1. object Main extends App {
  2. // your code goes here
  3. var x;
  4. if(true)
  5. {x = 5;} else {x = "test" ;}
  6. }
#7r8Bo6 Scala 9 hours ago
Compilation error
  1. val b = 2
  2. val a = (b += 2)
#1u5WP7 Scala 12 hours ago
Compilation error
  1. object Main extends App {
  2. def main(args: Array[String]) {
  3. println("Hello, world!")
  4. }// your code goes here
  5. }
#zeGTHP Scala 12 hours ago
Compilation error
  1. object Main extends App {
  2. // your code goes here
  3. a=5;
  4. b=10;
  5. c=a+b
  6.  
  7. }
#9PekfF Scala 12 hours ago
Compilation error
  1. 4
  2. 5
#p0klxY Scala 14 hours ago
Success
  1. object Main extends App {
  2. def p(a: String,b: String)={type D=List[Char]
  3. val d="0123456789".toList
  4. def v(s: String)=s.toList.map{c⇒d.takeWhile(c.!=)}
  5. def u(l:D, a:D):(Char,D)=l match {
  6. case _::_::_::_::_::_::_::_::_::_::m⇒u(m,'a'::a)
  7. case _(('a'::l).zip(d).last._2,a)}
  8. val o=(("", List[Char]())/:v(a).tails.toList.init.map{l⇒(v(b) map {_.flatMap(_⇒l.head)})++l.tail.map(_⇒Nil) reverse}.reduce(_.zipAll(_, Nil, Nil).map{t⇒t._1++t._2}))({(t,e)val s=u(t._2++e,Nil);(s._1+t._1,s._2)})
  9. u(o._2, Nil)._1+o._1}
#J20Kco Scala 23 hours ago
Compilation error
  1. import org.joda.time.DateTime
  2. import org.joda.time.format.DateTimeFormat
  3.  
  4.  
  5. object Main extends App {
  6. var df = DateTimeFormat.forPattern("YYMMdd")
  7. var d = DateTime.now()
  8. System.out.println(df.print(d))
  9. }
#eToiSA Scala 1 day ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. println("Hello, World");
  4. }
#WydRF2 Scala 1 day ago
Success
  1. object Main extends App {
  2.  
  3. trait Sleepy[A] { def sleep(n:Long):Unit }
  4. implicit val hoge = new Sleepy[Nothing]{
  5. def sleep(n:Long) = println("寝てる場合じゃねぇ!")
  6. }
  7.  
  8. def sleep[A:Sleepy] = try {
  9. implicitly[Sleepy[A]].sleep(1000)
#d8w1DE Scala 1 day ago
Success
  1. object Main extends App {
  2. val tv: Array[Array[Int]] = Array(
  3. Array(0, 1, 3, 4, 5),
  4. Array(1, 0, 2, 3, 4),
  5. Array(3, 2, 0, 1, 2),
  6. Array(4, 3, 1, 0, 1),
  7. Array(5, 4, 2, 1, 0))
  8.  
  9. val a = (0 until tv.length).permutations.toList
#GKJSuu Scala 1 day ago
Success
  1. object Main extends App {
  2. println()
  3. }
#mI1BfM Scala 1 day ago
Compilation error
  1. object Main extends App {
  2. val v = Vector('a','b','c')
  3. println(v.applyOrElse(3, '*'))
  4. }
#ra3KyX Scala 1 day ago
Compilation error
  1. object Main extends App {
  2. val a = List(1,2,3,4)
  3. for (i <- a) yield i+1
  4. println a
  5. }
#RH6zfz Scala 1 day ago
Compilation error
  1. object Main extends App {
  2. // your code goes here
  3. override def main(args:Array[String]){
  4.  
  5.  
  6.  
  7. //println(pair(double,triple)(3))
  8. val list = List("Once","more","unto","the","breach")
  9. val ltrs = list.map(_.toUppercase).flatMap(_.toList)
#AjWduc Scala 1 day ago
Compilation error
  1. object LongestIncreasingSubsequence extends App {
  2. def longest(l: Array[Int]) = l match {
  3. case _ if l.length < 2 => Array(l)
  4. case l =>
  5. def increasing(done: Array[Int], remaining: Array[Int]): Array[Array[Int]] = remaining match {
  6. case Array() => Array(done)
  7. case Array(head, _*) =>
  8. (if (head > done.last) increasing(done :+ head, remaining.tail) else Array()) ++
  9. increasing(done, remaining.tail) // all increasing combinations
#s7ls8r Scala 1 day ago
Success
  1. class C {
  2. override def toString: String = "C"
  3. }
  4.  
  5. object Main extends App {
  6. println(new C {
  7. override def toString = "inner class"
  8. })
  9. }
#72uIZw Scala 1 day ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. }
#oWFtzp Scala 1 day ago
Compilation error
  1. import Data.List
  2. import Control.Monad
  3. import Data.Maybe
  4. import qualified Data.Map as M
  5.  
  6. pickPattern :: Integer -> [[Integer]]
  7. pickPattern n = map (pick' [] n) [1..n]
  8. where
  9. pick' ns n1 n2
#j02znM Scala 1 day ago
Compilation error
  1. object Main extends App {
  2.  
  3. val sqCache = (1 to 1000).map(n => (Tuple2(n*n, true))).toMap
  4. def isSq(n:Int):Boolean = {
  5. sqCache.getOrElse(n, false)
  6. }
  7.  
  8. def helper(cand:List[Int], digits:List[Int], c:List[Int]):List[Int] = {
  9. cand match {
#tIfZlF Scala 1 day ago
Compilation error
  1. object Main extends App {
  2. def main(Array[String]){
  3. println("Foo")
  4. }
  5. }
#5gGehW Scala 1 day ago
Compilation error
  1. object CaseClassInheritance {
  2. abstract class Person {
  3. def name: String
  4. def age: Int
  5. // address and other properties
  6. // methods (ideally only accessors since it is a case class)
  7. def getName(): String = {
  8. return name
  9. }
#8uJxrX Scala 1 day ago
Compilation error
  1. object Main extends App {
  2. def sum(xs: List[Int]): Int = {
  3. if(xs.isEmpty)
  4. 0
  5. println("" + xs)
  6. // xs.head + sum(xs.tail)
  7. }
  8.  
  9. println(sum(List(1,2,3,4)))
#m593eN Scala 2 days ago
Success
  1. object Main extends App {
  2.  
  3. // -------- auxilliary functions --------
  4. def printLayout(layout: List[List[String]]): Unit =
  5. println((layout ++ List(List())).map(_.mkString).mkString("|\n").init)
  6. def renderCentered(txt: String, width: Int): String = {
  7. val rem = width - txt.size
  8. val (lSpan, rSpan) = (rem / 2, (rem + 1) / 2)
  9. "|" + " " * (lSpan - 1) + txt + " " * rSpan
#gsmCMV Scala 2 days ago
Compilation error
  1. object Main extends App {
  2.  
  3.  
  4. def dummy(n:Int, x:Int, y:Int):Int = {
  5. (for(a <- x to y if a%n==0) yield 1).sum
  6. } //> dummy: (n: Int, x: Int, y: Int)Int
  7.  
  8. def smart(n:Int, x:Int, y:Int):Int = {
  9. y/n - (x-1)/n
#iAWYbs Scala 2 days ago
Success
  1. object Main extends App {
  2.  
  3.  
  4. def dummy(n:Int, x:Int, y:Int):Int = {
  5. (for(a <- x to y if a%n==0) yield 1).sum
  6. } //> dummy: (n: Int, x: Int, y: Int)Int
  7.  
  8. def smart(n:Int, x:Int, y:Int):Int = {
  9. y/n - (x-1)/n
#akPPCb Scala 2 days ago
Compilation error
  1. object Main extends App {
  2. // your code goes here
  3. for(n<- 1 to 20; x <- 1 to 50; y <- x to 60 if smart(n,x,y) != dummy(n,x,y)){
  4. println((n,x,y)+" "+smart(n,x,y)+" "+ dummy(n,x,y))
  5. }
  6. }