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

#wLUA3c Scala 1 hour ago
Success
  1. object Main extends App {
  2. var line = readLine();
  3. while(false == line.equals("42")) {
  4. System.out.println(line);
  5. line = readLine();
  6. };
  7. }
#9SQCQp Scala 2 hours ago
Not running
  1. trait Similarity {
  2. def isSimilar(x: Any): Boolean
  3. def isNotSimilar(x: Any): Boolean = !isSimilar(x)
  4. }
  5.  
  6. class Point(xc: Int, yc: Int) extends Similarity {
  7. var x: Int = xc
  8. var y: Int = yc
  9. def isSimilar(obj: Any) =
#dZPE4w Scala 2 hours ago
Not running
  1. import java.util.{Date, Locale}
  2. import java.text.DateFormat._
  3.  
  4. object Today extends Application {
  5.  
  6. override def main(args: Array[String]) {
  7.  
  8. val now = new Date
  9. val frenchDateFormatter = getDateInstance(LONG, Locale.FRANCE)
#2rDYzc Scala 2 hours ago
Not running
  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. }
#I6ap6k Scala 2 hours ago
Not running
  1. /* Example of case class */
  2.  
  3.  
  4. case class Var(name: String) extends Term
  5. case class Fun(arg: String, body: Term) extends Term
  6. case class App(f: Term, v: Term) extends Term
  7.  
  8. object TermTest extends Application {
#os5yCn Scala 2 hours ago
Not running
  1. object HelloWorld extends Application {
  2. println("Hello, World!")
  3. }
#DwbeDx Scala 2 hours ago
Not running
  1. class HelloClass {
  2. def inClass() {
  3. println("In class")
  4. }
  5. }
  6.  
  7. object HelloObjectPlusClass {
  8. println("In object")
#7UbYvA Scala 2 hours ago
Not running
  1. object HelloObject {
  2. println("In object")
  3.  
  4. def main(args: Array[String]) {
  5. println("In main")
  6. }
  7.  
  8. }
#1q1Mlb Scala 2 hours ago
Not running
  1. object HelloClass {
  2.  
  3. abstract class Person {
  4. def name: String
  5. def age: Int
  6.  
  7. def getName(): String = {
  8. name
  9. }
#0ncbGI Scala 2 hours ago
Not running
  1. object FibonacciLister {
  2. def main(args: Array[String]) {
  3. val n = args(0).toInt
  4. var (a, b) = (0, 1)
  5. while (b <= n) {
  6. print(b + " ")
  7. var olda = a
  8. a = b
  9. b = a + b
#gATOt6 Scala 2 hours ago
Not running
  1. object Main {
  2. class MyString(val jString: String) {
  3. private var extraData = ""
  4. override def toString = jString + extraData
  5. }
  6. object MyString {
  7. def apply(base:String, extras:String) {
  8. val s = new MyString(base)
  9. s.extraData = extras
#w7aHt0 Scala 2 hours ago
Not running
  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. }
#W0pFiE Scala 2 hours ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. val a = List(1,2,3,4)
  4. val b = a.forall{
  5. mem =>
  6. val member = mem*mem
  7. (member == null) || (member < 10)
  8. }
  9. println(b)
#gLp0Xq Scala 2 hours ago
Success
  1. import scala.util.Random
  2.  
  3. object Main extends App {
  4. (1 to 20 map Random.nextInt).foreach(println)
  5. // your code goes here
  6. }
#B7xu4z Scala 6 hours ago
Compilation error
  1. object Main extends App {
  2. "hello world".foreach( println ( _ match { case 'l' => 'f' } ) )
  3. }
#54qaNq Scala 4 hours ago
Success
  1. object Main extends App {
  2.  
  3. var arr=new Array[Int](3);
  4. arr(0)=5;
  5. arr(1)=9;
  6. arr(2)=10;
  7.  
  8. for (i <-0 to (arr.length -1) )
  9. println(arr(i) )
#G5yJUf Scala 6 hours ago
Compilation error
  1. object Test {
  2. def main(args: Array[String]) {
  3. printStrings("Hello", "Scala", "Python");
  4. }
  5. def printStrings( args:String* ) = {
  6. var i : Int = 0;
  7. for( arg <- args ){
  8. println("Arg value[" + i + "] = " + arg );
  9. i = i + 1;
#yJ2fLB Scala 8 hours ago
Success
  1. import scala.util.{Try, Success, Failure}
  2.  
  3.  
  4.  
  5. object Main extends App {
  6. def divide: Try[Int] = {
  7. val dividend = Try(Console.readLine("Enter an Int that you'd like to divide:\n").toInt)
  8. val divisor = Try(Console.readLine("Enter an Int that you'd like to divide by:\n").toInt)
  9. val problem = dividend.flatMap(x => divisor.map(y => x/y))
#siFTPH Scala 8 hours ago
Success
  1. import scala.util.{Try, Success, Failure}
  2.  
  3.  
  4.  
  5. object Main extends App {
  6. def divide: Try[Int] = {
  7. val dividend = Try(Console.readLine("Enter an Int that you'd like to divide:\n").toInt)
  8. val divisor = Try(Console.readLine("Enter an Int that you'd like to divide by:\n").toInt)
  9. val problem = dividend.flatMap(x => divisor.map(y => x/y))
#uQdIHT Scala 8 hours ago
Compilation error
  1. import scala.util.{Try, Success, Failure}
  2.  
  3. def divide: Try[Int] = {
  4. val dividend = Try(Console.readLine("Enter an Int that you'd like to divide:\n").toInt)
  5. val divisor = Try(Console.readLine("Enter an Int that you'd like to divide by:\n").toInt)
  6. val problem = dividend.flatMap(x => divisor.map(y => x/y))
  7. problem match {
  8. case Success(v) =>
  9. println("Result of " + dividend.get + "/"+ divisor.get +" is: " + v)
#A3AipN Scala 12 hours ago
Success
  1. object Main extends App {
  2. print(List(1,2,3).reverse)
  3. }
#zQG8Jt Scala 14 hours ago
Success
  1. object Hoge {
  2. def hoge = "hoge"
  3. }
  4.  
  5. object Main extends App {
  6. println(Hoge.hoge(2))
  7. }
#s2kndc Scala 14 hours ago
Compilation error
  1. object Hoge {
  2. def hoge = "hoge"
  3. }
  4.  
  5. object Main extends App {
  6. println(Hoge.hoge()(2))
  7. }
#Zs99Dp Scala 14 hours ago
Success
  1. object Hoge {
  2. def hoge () = "hoge"
  3. }
  4.  
  5. object Main extends App {
  6. println(Hoge.hoge()(2))
  7. }
#2nQKpu Scala 14 hours ago
Compilation error
  1. object Hoge {
  2. def hoge () = "hoge"
  3. }
  4.  
  5. object Main extends App {
  6. println(Hoge.hoge(2))
  7. }
#rfzguK Scala 14 hours ago
Success
  1. object Hoge {
  2. def hoge () = "hoge"
  3. }
  4.  
  5. object Main extends App {
  6. println(Hoge.hoge)
  7. }
#BYqXW4 Scala 14 hours ago
Success
  1. object Main extends App {
  2. println("hoge"(2))
  3. }
#ZA9GLq Scala 17 hours ago
Success
  1. object Main extends App {
  2. def f(x: Int) = x + 2;
  3.  
  4. def y(x: Int => Int) = x(10)
  5.  
  6. val answer = y(f)
  7.  
  8. println(answer)
  9. }
#Vy4b1M Scala 18 hours ago
Time limit exceeded
  1. object Main extends App {
  2.  
  3. object Q1119{
  4.  
  5. val sqCache = (1 to 1000).map(n => (Tuple2(n*n, true))).toMap
  6. def isSq(n:Int):Boolean = {
  7. sqCache.getOrElse(n, false)
  8. }
#7NiXSO Scala 19 hours ago
Success
  1. object Main extends App {
  2. val hex = 0x0FF
  3. println(hex)
  4. }