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

#uwa9Bh Scala 3 hours ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. val message = "Hector Miuler Malpica Gallegos, edad 34"
  4.  
  5. var msg = ("[\\w]"r).findAllIn(message toUpperCase).mkString
  6.  
  7. msg += "X" * (msg.length % 5)
  8.  
  9. println(msg grouped 5 toList)
#rrmVlC Scala 5 hours ago
Success
  1. object Main extends App {
  2. val listOfLists = List(List(1, 2, 3), List(10, 20))
  3. val cartesianProduct = listOfLists.foldRight(List(Nil): List[List[Int]])((l1, l2) =>
  4. l1.flatMap(i =>
  5. l2.map(l => i :: l)
  6. )
  7. )
  8.  
  9. println(cartesianProduct) // [[1, 10], [1, 20], [2, 10], [2, 20], [3, 10], [3, 20]]
#vZLBsX Scala 12 hours ago
Success
  1. object Main extends App {
  2.  
  3. }
#z8NLD4 Scala 16 hours ago
Success
  1. object Main extends App {
  2. val AuctivaLink = """^http(s?)://www\.auctiva\.com/hostedimages/showimage\.aspx.*""".r
  3. val s = "http://www.auctiva.com/hostedimages/showimage.aspx?gid=1652277&image=750034566&images=750034493,750034497,750034504,750034512,750034518,750034525,750034528,750034535,750034563,750034566&formats=0,0,0,0,0,0,0,0,0,0&format=0"
  4.  
  5. println(AuctivaLink.findFirstIn(s))
  6. println(AuctivaLink.unapplySeq(s))
  7. }
#nedbMg Scala 16 hours ago
Success
  1. object Main extends App {
  2. val AuctivaLink = """^http(s?)://www\.auctiva\.com/hostedimages/showimage\.aspx""".r
  3. val s = "http://www.auctiva.com/hostedimages/showimage.aspx?gid=1652277&image=750034566&images=750034493,750034497,750034504,750034512,750034518,750034525,750034528,750034535,750034563,750034566&formats=0,0,0,0,0,0,0,0,0,0&format=0"
  4.  
  5. println(AuctivaLink.findFirstIn(s))
  6. println(AuctivaLink.unapplySeq(s))
  7. }
#QyVJ9I Scala 18 hours ago
Success
  1. object Main extends App {
  2. println("hello world")
  3. }
#kfkIW6 Scala 19 hours ago
Success
  1. object Main extends App {
  2.  
  3. var (x, y, z, c, python, java) = (1, 2, 3, true, false, "no!") //> "no!"
  4. println(x, y, z, c, python, java)
  5. }
#hLkH8x Scala 20 hours ago
Success
  1. object Main extends App {
  2. def createInitList(r:Range, depth:Int):Map[Int, Int] = {
  3. depth match {
  4. case x if x<0 => Map(1 -> 1)
  5. case 1 => r.map(v=> (v->1)).toMap
  6. case n => {
  7. val m = createInitList(r, depth-1)
  8. val ret = collection.mutable.Map[Int, Int]().withDefaultValue(0)
  9. for(k <- r; v <- m){
#CWdYvI Scala 21 hours ago
Compilation error
  1. object HelloWorld {
  2. def totalSelectedValues(values: List[Int],
  3. selector : Int => Boolean) = {
  4. var total = 0
  5. for( e <- values) {
  6. if (selector(e)) total +=e
  7. }
  8. total
  9. }
#XNbKek Scala 21 hours ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. object HelloWorld {
  4. def totalSelectedValues(values: List[Int],
  5. selector : Int => Boolean) = {
  6. var total = 0
  7. for( e <- values) {
  8. if (selector(e)) total +=e
  9. }
#pjoFTw Scala 21 hours ago
Success
  1. object Main extends App {
  2. def totalSelectedValues(values: List[Int],
  3. selector : Int => Boolean) = {
  4. var total = 0
  5. values.foreach { e =>
  6. if(selector(e)) total += e
  7. }
  8. total
  9. }
#51MtZK Scala 23 hours ago
Success
  1. object Main extends App {
  2. println("hello")
  3. }
#1rFk09 Scala 1 day ago
Success
  1. object Main extends App {
  2. //Есть продукты A, B, C, D, E, F, G, H, I, J, K, L, M. Каждый продукт стоит определенную сумму.
  3. //
  4. //Есть набор правил расчета итоговой суммы:
  5. //
  6. //Если одновременно выбраны А и B, то их суммарная стоимость уменьшается на 10% (для каждой пары А и B)
  7. //Если одновременно выбраны D и E, то их суммарная стоимость уменьшается на 5% (для каждой пары D и E)
  8. //Если одновременно выбраны E,F,G, то их суммарная стоимость уменьшается на 5% (для каждой тройки E,F,G)
  9. //Если одновременно выбраны А и один из [K,L,M], то стоимость выбранного продукта уменьшается на 5%
#KLT6w8 Scala 1 day 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) =
#BrjCtP Scala 1 day 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)
#rwK74h Scala 1 day ago
Not running
  1.  
#TNyvuz Scala 1 day 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 {
#kATPQf Scala 1 day ago
Not running
  1. object HelloWorld extends Application {
  2. println("Hello, World!")
  3. }
#FALnU6 Scala 1 day ago
Not running
  1. class HelloClass {
  2. def inClass() {
  3. println("In class")
  4. }
  5. }
  6.  
  7. object HelloObjectPlusClass {
  8. println("In object")
#4Svonj Scala 1 day ago
Not running
  1. object HelloObject {
  2. println("In object")
  3.  
  4. def main(args: Array[String]) {
  5. println("In main")
  6. }
  7.  
  8. }
#grtYHJ Scala 1 day 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. }
#hdxFx9 Scala 1 day 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
#CyHtVB Scala 1 day 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
#PfsdUG Scala 1 day 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. }
#XprKsx Scala 1 day 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) =
#t0jtse Scala 1 day 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)
#4oUuxm Scala 1 day ago
Not running
  1.  
#yPL6y0 Scala 1 day 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 {
#x96HAQ Scala 1 day ago
Not running
  1. object HelloWorld extends Application {
  2. println("Hello, World!")
  3. }
#9RN47B Scala 1 day ago
Not running
  1. class HelloClass {
  2. def inClass() {
  3. println("In class")
  4. }
  5. }
  6.  
  7. object HelloObjectPlusClass {
  8. println("In object")