Skip to main content
Commonmark migration
Source Link

##Scala, 145 chars

Scala, 145 chars

def d(n:Int):Int=if(n<10)n*n else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))} 

##Scala, 145 chars

def d(n:Int):Int=if(n<10)n*n else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))} 

Scala, 145 chars

def d(n:Int):Int=if(n<10)n*n else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))} 
recalc
Source Link
user unknown
  • 4.6k
  • 32
  • 32

##Scala, 146145 chars

def d(n:Int):Int=if(n<10)(n*n) else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))} 

##Scala, 146 chars

def d(n:Int):Int=if(n<10)(n*n)else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))} 

##Scala, 145 chars

def d(n:Int):Int=if(n<10)n*n else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))} 
Source Link
user unknown
  • 4.6k
  • 32
  • 32

##Scala, 146 chars

def d(n:Int):Int=if(n<10)(n*n)else d(n%10)+d(n/10) def h(n:Int):Unit=n match{ case 1=>println("happy") case 4=>println("unhappy") case x=>h(d(x))}