This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def yolo( x ): | |
p1 = x * x * x | |
p2 = x + x * x + x * x * x | |
if p1 < (1<<x) and (1<<x) < p2 and x != (x-(~(-x))): | |
print ( (x/(x/2))*(x-(~x)) ) | |
else: | |
yolo(x + 1) | |
yolo(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply( f:List[Any => String], x:Any ):Any = f match { | |
case h :: t => apply( t, h(x) ) // applies function while iterating on the given functions List | |
case _ => x // if [end_of_list] -> return 'x' | |
} | |
def test( x:Any ) = { | |
val ts = (x:Any) => x.toString // function converting val to String (returns a String) | |
val br = (x:Any) => "[" + x + "]" // function putting val between brackets (returns a String) | |
val list = ts :: br :: Nil // list containing previous functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(n:Int):BigInt = ((1 to n) :\ BigInt(1))(_ * _) | |
// (1 to n).foldLeft(BigInt(1))(_ * _) | |
def recFactorial(n:Int):BigInt = if (n < 2) n else n * recFactorial(n-1) | |
def tailRecFactorial(n:Int):BigInt = { | |
def fac(n:Int, acc:BigInt):BigInt = n match { | |
case 1 => acc | |
case _ => fac(n-1, n*acc) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val f0 = (g0:Int=>Int, x:Int) => g0(x) | |
val h0 = ( x:Int ) => f0( p=>p+1, x ) | |
println( "41 + 1 = " + h0(41) ) | |
/******************************************************************************/ | |
/******************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URL | |
import java.io.File | |
import javax.imageio.ImageIO | |
//lazy val file = new File( "/tmp/testing" ) | |
lazy val file = new URL( "http://goo.gl/vOYtrv" ) | |
lazy val img = ImageIO.read( file ) | |
lazy val width = img.getWidth | |
lazy val height = img.getHeight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dimRefs = ( 160, 190 ) | |
def deleteFile( name:String ) = new File(name).delete | |
def createImage( name:String ):BufferedImage = name match { | |
case n if n startsWith "http://" => ImageIO.read( new URL (name) ) | |
case n if n startsWith "https://" => ImageIO.read( new URL (name) ) | |
case _ => ImageIO.read( new File(name) ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object LeetCrypt | |
{ | |
implicit class Encrypt( src:String ) | |
{ | |
def leetOfString( s:String ) = { | |
s.map( | |
c => c match { | |
case 'a' | 'A' => '4' | |
case 'b' => '6' | |
case 'B' => '8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def infiniteArg( arg:Any* ) = arg.foreach( println ) | |
infiniteArg( 1, 2, 3 ) | |
infiniteArg( "1", 2, '3' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.Source | |
object Main { | |
def formatInfos( infos:Array[String], password:String ) = { | |
val source = infos | |
.filter( _.contains("0x00000007 <blob>=") ).head.split( "<blob>=" ).last | |
val login = infos | |
.filter( _.contains("\"acct\"<blob>=") ).head.split( "<blob>=" ).last |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
import scala.util.parsing.json._ | |
object Main | |
{ | |
/* | |
** FLICKR SPECIFIC FUNCTIONS | |
*/ | |
def getFlickrInfosJson( content:String ) = { | |
val rawJson = content.split("\n") |