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

Filter by: All Bash C C# C++ 4.9.2 C++14 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 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) Python (Pypy) R Scala Scheme (chicken) Scheme (guile) Smalltalk Tcl Text Unlambda Whitespace

#xd4q1N Scala 26 minutes ago
Success
  1. abstract class CardSuit{val str = "";override def toString() : String = str}
  2. case object Spades extends CardSuit{override val str = "s"}
  3. case object Clubs extends CardSuit{override val str = "c"}
  4. case object Hearts extends CardSuit{override val str = "h"}
  5. case object Diamonds extends CardSuit{override val str = "d"}
  6.  
  7. object Main extends App {
  8. import Hearts._
  9. val he = Hearts
#UqtN2s Scala 1 hour ago
Compilation error
  1. /* Solution to SPOJ problem "Complete the Sequence!"
  2.  * (https://www.spoj.pl/problems/CMPLS/) in Scala. Written in Scala 2.8.
  3.  */
  4. object Main {
  5.  
  6. def main(args: Array[String]) {
  7. val noOfTestCases: Int = readInt
  8. 1 to noOfTestCases foreach { i =>
  9. val input = readLine.trim.split(" ").map { _ toInt }
#Y5LSah Scala 2 hours 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. }
#DrLjET Scala 1 hour ago
Success
  1. class Foo
  2. {
  3. private var hoge: String = _
  4.  
  5. def this(hoge: Int){this(); this.hoge = Integer.toString(hoge)}
  6. def getHoge = hoge
  7. }
  8.  
  9. object Main extends App
#hCgHgf Scala 3 hours ago
Compilation error
  1. object Main extends App {
  2. val f = (a: Any, b: Any) => (a, b)
  3. val a = List(1, 2, 3)
  4. val b = List('a', 'b', 'c')
  5. println(a zipWith(f) b)
  6. }
#0QokWr Scala 4 hours ago
Success
  1. import scala.collection.mutable.Map;
  2.  
  3. object Main extends App {
  4. var x = Map[String, Map[String, Int]]();
  5. x += "cool" -> Map("look" -> 3);
  6. x += "cool" -> Map("lenk" -> 4);
  7. x += "look" -> Map[String,Int]();
  8. x("cool")("pool") = 1;
  9. x("look")("cool") = 3;
#F8UaZF Scala 5 hours ago
Success
  1. object Main extends App {
  2. println("Hello world")
  3. }
#ceS2Gi Scala 4 hours ago
Runtime error
  1. import scala.collection.mutable.Map
  2.  
  3. object Main extends App {
  4. var x = Map[Int, Map[Int, Int]]();
  5. x(1)(2) = 3
  6. println(x(1)(2));
  7. }
#ZIe9ju Scala 5 hours ago
Compilation error
  1. object Main extends App {
  2. val s: (() => ()) = { println("Hello world") }
  3.  
  4. s()
  5. }
#FF8GLD Scala 5 hours ago
Compilation error
  1. /* Solution to SPOJ problem "Complete the Sequence!"
  2.  * (https://www.spoj.pl/problems/CMPLS/) in Scala. Written in Scala 2.8.
  3.  */
  4. object Main {
  5.  
  6. def main(args: Array[String]) {
  7. val noOfTestCases: Int = readInt
  8. 1 to noOfTestCases foreach { i =>
  9. val input = readLine.trim.split(" ").map { _ toInt }
#viBBq8 Scala 5 hours ago
Success
  1. import scala.collection.mutable.PriorityQueue
  2.  
  3. case class Node(var distance: Double, var path: String, var visited: Boolean)
  4. extends Ordered[Node]{
  5. def compare(other: Node) = other.distance.compare(distance);
  6. }
  7.  
  8. object Main extends App {
  9. var x = PriorityQueue[Node]();
#qbDZWU Scala 6 hours ago
Compilation error
  1. import scala.collection.mutable.Map
  2. import scala.collection.mutable.PriorityQueue
  3.  
  4. case class Node(x: Double, y: String, z: Boolean) extends Ordered[Node]{
  5. def compare(other: Node) = other.x.compare(x);
  6. }
  7.  
  8. object Main extends App {
  9. var x = new PriorityQueue[Node]();
#zPC12d Scala 8 hours ago
Compilation error
  1. import scala.collection.mutable.Map
  2. import scala.collection.mutable.PriorityQueue
  3.  
  4. class Node(s: Int){
  5. var x: Int = s;
  6.  
  7. def compare(that: Node) = that.x.compare(this.x);
  8. }
#8V9iAM Scala 10 hours ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. println(s"Hello World")
  4. }
#mEfmJ5 Scala 11 hours ago
Compilation error
  1. object Main extends App {
  2. "mysql" % "mysql-connector-java" % "5.1.+"
  3. }
#72oc5U Scala 12 hours ago
Compilation error
  1. (define (member? bst x)
  2. (cond
  3. ((null? bst) #f)
  4. ((= x (car bst)) #t)
  5. ((< x (car bst)) (member? (car(cdr bst)) x))
  6. (else (member? (car(cdr(cdr bst))) x))))
  7.  
  8. (define (insert bst x)
  9. (cond
#KkdQqg Scala 14 hours ago
Runtime error
  1. object Main extends App {
  2. // your code goes here
  3. val x = 45
  4. println(s"Hex: ${Integer.toHexString(x)}")
  5. println(s"Binary: ${Integer.toBinaryString(x)}")
  6.  
  7. println(Integer.decode("0x700045802082101F"))
  8.  
  9. }
#GkKogU Scala 15 hours ago
Compilation error
  1. sealed trait Tree[+A] {
  2. def insert[B >: A](elem: B)(implicit x: Ordering[B]) : Tree[B]
  3. def toString : String
  4. }
  5.  
  6. object Empty extends Tree[Nothing] {
  7. def insert[A](elem: A)(implicit x: Ordering[A]) : Tree[A] = TreeNode(elem, Empty, Empty)
#HdfXvM Scala 17 hours ago
Compilation error
  1. object Main extends App {
  2.  
  3.  
  4. def main(args: Array[String]) {
  5. var a=2*3
  6. println(a)
  7. }
  8.  
#lszVtU Scala 17 hours ago
Compilation error
  1. object HelloScala {
  2.  
  3. def main(args: Array[String]) {
  4. var a=2*3
  5. println(a)
  6. }
  7. }
#9HxGSq Scala 17 hours ago
Compilation error
  1. object hello {
  2.  
  3. def main(args: Array[String]) {
  4. println("Hello")
  5.  
  6. }
  7. }
#FeZqu6 Scala 19 hours ago
Compilation error
  1. object Main extends App {
  2. val l = List(1,2,3,4)
  3. l = l.map( _ * 2)
  4. }
#8CPaIV Scala 20 hours ago
Success
  1. object Main extends App {
  2. List("Carsten", "Kevin", "Joran").foreach(x => println(s"Cabbage to $x"))
  3. }
#p4jGOs Scala 22 hours ago
Success
  1. object Main extends App {
  2. new Bar()
  3. }
  4.  
  5. class Foo {
  6. _private()
  7. _protected()
  8. _public()
#Zy9M6H Scala 22 hours ago
Compilation error
  1. object Main extends App {
  2. new Bar()
  3. }
  4.  
  5. class Foo {
  6. _private()
  7. _protected()
  8. _public()
#PhE8IV Scala 22 hours ago
Success
  1. object Main extends App {
  2. val l:Long = 1401580744341L
  3. val n = System.currentTimeMillis
  4.  
  5. val d = n - l
  6.  
  7. println("allora: "+l)
  8. println("adesso: "+n)
  9. println("diff: "+d)
#pP7tHF Scala 1 day ago
Success
  1. object Main extends App {
  2. val l = System.currentTimeMillis
  3.  
  4. println(l)
  5. }
#nwHBOz Scala 1 day ago
Success
  1. object Main extends App {
  2.  
  3. val usList = for {a <- 1 to 1000
  4. b = (500000 - 1000 * a.toFloat) / (1000 - a.toFloat)
  5. if (b % 10 == 0)
  6. if (b > 0 && 1000 - a - b > 0)
  7. }
  8. yield a * b.toInt * (1000 - a - b).toInt
  9. println(usList)
#9GQY2y Scala 1 day ago
Compilation error
  1. object Main extends App {
  2. val javaMap = new util.HashMap[Int,Int](){
  3. for (i <- 1 to 20)
  4. put(i,i+1)
  5. }
  6.  
  7. import collection.JavaConverters._
  8. val scalaMap = javaMap.asScala.toMap
#xbALIN Scala 1 day ago
Compilation error
  1. val cells = for (x <- 0 to map.width, y <- 0 to map.height) yield(x, y)
  2. val maxPriorityCell = cells.maxBy(c => cellPriorities(c._1, c._2))