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

#nyO9Yj Scala 13 hours ago
Compilation error
  1.  
  2. object Pf {
  3. val md = java.security.MessageDigest.getInstance("SHA-1")
  4.  
  5. def getDigest(str: String): String =
  6. md.digest(str.getBytes("UTF-8")).map("%02x".format(_)).mkString
  7.  
  8. def readSource(): String = {
  9. val filename = getFilename()
#P3tQPb Scala 17 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. }
#mAoBp9 Scala 19 hours ago
Compilation error
  1. object Main extends App {
  2. val rowList =
  3. """|37107287533902102798797998220837590246510135740250
  4. |46376937677490009712648124896970078050417018260538
  5. |74324986199524741059474233309513058123726617309629
  6. |91942213363574161572522430563301811072406154908250
  7. |23067588207539346171171980310421047513778063246676
  8. |89261670696623633820136378418383684178734361726757
  9. |28112879812849979408065481931592621691275889832738
#yswESU Scala 21 hours ago
Success
  1. object Main extends App {
  2. val candidates = Seq(
  3. "Janusz Ryszard Korwin-Mikke",
  4. "Bronisław Maria Komorowski",
  5. "Adam Sebastian Jarubas",
  6. "Paweł Piotr Kukiz",
  7. "Marian Janusz Kowalski",
  8. "Jacek Wilk",
  9. "Andrzej Sebastian Duda",
#1ZEBGl Scala 21 hours ago
Compilation error
  1. object Main extends App {
  2. val candidates = Seq(
  3. "Janusz Ryszard Korwin-Mikke",
  4. "Bronisław Maria Komorowski",
  5. "Adam Sebastian Jarubas",
  6. "Paweł Piotr Kukiz",
  7. "Marian Janusz Kowalski",
  8. "Jacek Wilk",
  9. "Andrzej Sebastian Duda",
#UllpKI Scala 23 hours ago
Compilation error
  1. import java.util.UUID
  2. case class Channel(id: UUID, name: String, phoneNumber: Option[String])
  3. case class User(id: UUID, name: String)
  4. case class Following(channelId: UUID, UserId: UUID)
  5. case class PhoneNumber(number: String)
  6.  
  7. object DataStore {
  8. import scala.collection.mutable.{List => MList}
  9. val Channels: MList = _
#XaCTWx Scala 1 day ago
Compilation error
  1. class Car(yr : Int){
  2. println("created a new car")
  3. }
  4. val car1 = new Car(2)
#5kh6KM Scala 1 day ago
Success
  1. object Main extends App {
  2. def inspect[T](l: List[T])(implicit manifest: scala.reflect.Manifest[T]) = manifest.toString()
  3. val list = 1 :: 2 :: 3 :: 4 :: 5 :: Nil
  4.  
  5. println(inspect(list))
  6. }
#SiEYQs Scala 1 day ago
Success
  1. object Main extends App {
  2. val s = BigDecimal(0)
  3. }
#LnODxg Scala 1 day ago
Success
  1. object Main extends App {
  2. val t = new Test
  3. println(t.foor)
  4. }
  5.  
  6. class Test{
  7. var foo = 0
  8. val bar = 0
  9. def foor_=(n:Int) = {foo = n}
#laIsc2 Scala 2 days ago
Success
  1. class Foo {
  2. def wat(): String = "hi"
  3. def bar(): Int = 3
  4. }
  5.  
  6. object Main extends App {
  7.  
  8. implicit class ChangeFoo(x: Foo) extends Foo {
  9. override def wat(): String = "implicit wat"
#NvP5mK Scala 2 days ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. }
#FOaXSw Scala 2 days ago
Compilation error
  1. object Main extends App {
  2. val pattern = """(?:([http|https]://)?)(?:(www\.)?)([A-Za-z0-9._%+-]+)[/]?(?:.*)""".r
  3. url match {
  4. case pattern(domain) =>
  5. print(domain)
  6. case _ => print("not found!")
  7. }
  8. }
#62CVbh Scala 2 days ago
Success
  1. object Main extends App {
  2. println("Hello, world!")
  3. }
#hfhi9f Scala 2 days ago
Success
  1. object Main extends App {
  2.  
  3. def square(m: Double) = m * m
  4. val sq = square _
  5. println( sq( 4) )
  6.  
  7. }
#3PfaUf Scala 2 days ago
Success
  1. object Main extends App {
  2. val string = "one493two483three"
  3. val pattern = """two(\d+)three""".r
  4. pattern.findAllIn(string).matchData foreach {
  5. m => println(m.group(1))
  6. }
  7. // your code goes here
  8. }
#m6CwNg Scala 2 days ago
Success
  1. object Main extends App {
  2.  
  3. trait Foo[T] { def doStuff(t : T) : Unit }
  4. object Foo { def doStuff[T : Foo](t : T) = implicitly[Foo[T]].doStuff(t) }
  5.  
  6. implicit object IntFoo extends Foo[Int] { def doStuff(x : Int) = println(x * 10) }
  7. implicit object StringFoo extends Foo[String] { def doStuff(s : String) = println(s"Incoming string: $s") }
  8.  
  9. Foo.doStuff(10)
#ur83cA Scala 3 days ago
Success
  1. object Main extends App {
  2. val theme = "Na " * 16 + "Batman!"
  3. println(theme)
  4. }
#V4EBq2 Scala 3 days ago
Compilation error
  1. #define cardinal 5
  2. substitute=1
  3. initially=0
  4. initially2=cardinal/2
  5. loop:
  6. initially_intermediate=initially
  7. initially2_intermediate=initially2
  8. arr[initially][initially2]=substitute;
  9. initially=initially-1
#Q1pfdi Scala 3 days ago
Success
  1. object Main extends App {
  2. val list : List[Int] = List.empty;
  3. val list2 : List[Int] = List(1,2)
  4. val (lessThan2, greaterThan2) = list.partition(x => List(1,2).exists(_ == x));
  5. print (lessThan2);
  6. print (greaterThan2);
  7. }
#xwPP3M Scala 3 days ago
Success
  1. sealed class Foo[T] {
  2. def doStuff() = println(1)
  3. }
  4. object Foo {
  5. def apply[T]() = new Foo[T]()
  6. }
  7. object Main extends App {
  8. Foo[Int].doStuff()
  9. }
#7irbla Scala 1 day ago
Success
  1. object Main extends App {
  2. def lambda = { x: Int => x + 1 }
  3. val result1andhalf = lambda.apply(3)
  4. Console.println(result1andhalf)
  5. }
#3cpBNL Scala 3 days ago
Success
  1. import scala.collection.mutable._
  2.  
  3. object Main extends App {
  4. def HashMapOrdering = new Ordering[HashMap[Int,Int]] {
  5.  
  6. def compare(a : HashMap[Int,Int], b : HashMap[Int,Int]) = b.valuesIterator.next().compare(a.valuesIterator.next())
  7.  
  8. }
#h9ICRn Scala 3 days ago
Compilation error
  1. import com.github.nscala_time.time.Imports._
  2. import org.joda.time._
  3.  
  4. object Main extends App {
  5. // your code goes here
  6. }
#Xzz6xc Scala 3 days ago
Success
  1. object Main extends App {
  2. val nums = (1 to 100).toList
  3.  
  4. def fb(x: Int, f: String, s: String) =
  5. (x%3, x%5) match {
  6. case (0, 0) => f + s
  7. case (_, 0) => f
  8. case (0, _) => s
  9. case (_, _) => x.toString
#siBIdy Scala 3 days ago
Compilation error
  1. object Main extends App {
  2.  
  3. def omer(var c):
  4. println("hi");
  5. // your code goes here
  6. }
#OfeieJ Scala 3 days ago
Success
  1. object Main extends App {
  2. val MAX_SIZE = 1000000
  3. val reduceLeftStartTime = new java.util.Date
  4. (1 to MAX_SIZE) reduceLeft (_ + _)
  5. val reduceLeftEndTime = new java.util.Date
  6.  
  7.  
  8. val reduceRightStartTime = new java.util.Date
  9. (1 to MAX_SIZE) reduceRight (_ + _)
#os0txW Scala 3 days ago
Success
  1. object Main extends App {
  2. val list = List(5, 4, 3, 2, 1)
  3. val result = (list :\ 0) {
  4. (`next element`, `running total`) => `next element` - `running total`
  5. }
  6.  
  7. println(result)
  8.  
  9. }
#hBzKnV Scala 3 days ago
Compilation error
  1. object TimerExample {
  2. /** Runs the passed in function pausing approxmimately one second in between calls.
  3.   * as long as the function returns true.
  4.   */
  5. def oncePerSecond(callback: () => Boolean) {
  6. while(callback()) {
  7. Thread sleep 1000
  8. }
  9. }
#MtdFHf Scala 3 days ago
Success
  1. object Main extends App {
  2. val abc = (1 to 1000).toList
  3.  
  4. val startTime1 = System.currentTimeMillis()
  5. val v1 = abc.scanLeft(List[Int]()) {
  6. (a, acc)=> a ++ List(acc)
  7. }.tail
  8. val endTime1 = System.currentTimeMillis()
  9. println(s"1: ${endTime1 - startTime1} ms")