I hereby claim:
- I am jackliusr on github.
- I am jackliusr (https://keybase.io/jackliusr) on keybase.
- I have a public key ASAclF7K6ROgP0Ubzeq8Wa5_UqzUP9FE75PCKzc7xvDjYAo
To claim this, I am signing this object:
import scala.math.BigInt | |
object Solution { | |
def main(args: Array[String]) { | |
val lines = io.Source.stdin.getLines().drop(1).toList | |
val nums = lines.map(l => l.toInt) | |
def decentNum(n: Int) : String ={ | |
for( i <- (n to 0 by -1) ) { | |
if( i % 3 ==0 && (n -i) % 5 ==0 ) return ("5" * i + "3" * (n-i)) | |
} | |
return "-1"; |
object Solution { | |
def main(args: Array[String])={ | |
val lines = io.Source.stdin.getLines.drop(1) | |
def gcd(a: Int, b: Int) : Int = if(b == 0) a else gcd(b, a % b) | |
val tcs = lines.grouped(2).map( v => v(1)).map(l=>l.split("\\s+").map( s => s.toInt)) | |
val results = tcs.map(c => c.reduceLeft(gcd)) | |
results.foreach( r => println(if( r > 1) "NO" else "YES" )) | |
import scala.math.BigInt | |
object Solution { | |
def main(args: Array[String]) = { | |
def fibFrom(a: BigInt, b: BigInt): Stream[BigInt] = a #:: fibFrom(b, a + b) | |
val lines = io.Source.stdin.getLines.drop(1).toList | |
val nums:List[BigInt] = lines.map( l => BigInt(l)) | |
def isFib(n: BigInt):String = { | |
val fs = fibFrom(0,1).takeWhile(f => f <= n).toList | |
if (fs.last < n ) "IsNotFibo" else "IsFibo" | |
} |
object Solution{ | |
def main(args: Array[String]) ={ | |
val lines = io.Source.stdin.getLines.drop(1).toList | |
val k = lines(0).toInt | |
val kNumsSets = lines.drop(1).map( l => BigInt(l)).sorted.toArray | |
var unfairness = kNumsSets.last | |
for(i <- 0 to kNumsSets.size -k -1){ | |
val diff= kNumsSets(i + k-1 ) - kNumsSets(i) | |
if( diff < unfairness) unfairness = diff | |
} |
object Solution { | |
def main(args: Array[String]) = { | |
val lines = io.Source.stdin.getLines.toList | |
val nums = lines.map( l => l.split("\\s+").map(s => s.toLong)) | |
var a = nums(1).toArray | |
val b = nums(2).toArray | |
val c = nums(3).toArray | |
val n = (nums(0)(0) -1).intValue | |
val m = (nums(0)(1) -1).intValue | |
val mod = scala.math.pow(10,9).toInt + 7 |
I hereby claim:
To claim this, I am signing this object:
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.json", | |
"data": { | |
"url": "https://data.gov.sg/api/action/datastore_search?resource_id=4ad866a7-c43a-4645-87fd-fc961c9de78a", | |
"format": { "type": "json","property": "result.records"} | |
}, | |
"mark": "line", | |
"encoding": { | |
"x": {"field": "year", "type": "nominal"}, | |
"y": {"field": "enrolment", "type": "quantitative"} |
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.json", | |
"width": 500, | |
"height": 300, | |
"data": { | |
"url": "https://api.data.gov.sg/v1/environment/2-hour-weather-forecast", | |
"format": { "type": "json","property": "area_metadata"} | |
}, | |
"projection": { | |
"type": "equalEarth" |
{ | |
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", | |
"awards": [ ], | |
"basics": { | |
"email": "jack.liu.s.r@gmail.com", | |
"image": "", | |
"label": "Solutions Architect at Bidot Technology", | |
"location": { | |
"address": "Yishun,Singapore", | |
"countryCode": "SG" |
Block or filter IPs based on location in Nginx (tested on 1.18.0) on Ubuntu 20.04.
To make use of the geographical filtering, we must first install the Nginx GeoIP module as well as the GeoIP database containing the mappings between visitors’ IP addresses and their respective countries. To do so, let’s execute:
$ sudo apt install libnginx-mod-http-geoip geoip-database