Skip to content

Instantly share code, notes, and snippets.

View ricky-lim's full-sized avatar
:octocat:
focusing

Ricky Lim ricky-lim

:octocat:
focusing
View GitHub Profile
@ricky-lim
ricky-lim / countVowelAndConsonant.java
Created March 30, 2022 11:48
Count vowels and consonants
import java.util.List;
import java.util.stream.Collectors;
class Scratch {
public static void countVowelAndConsonant(String s) {
String VOWELS = "aeiouy";
String normalized = s.toLowerCase().trim();
List<Integer> letters = normalized.chars()
@ricky-lim
ricky-lim / maxProduct.java
Created March 31, 2022 18:24
Find max products
import java.util.Arrays;
class Scratch {
public static int maxProduct(int[] numbers) {
int length = numbers.length;
if (length < 2) {
throw new IllegalArgumentException(String.format("Require at least 2 numbers. But given: %s", Arrays.toString(numbers)));
}
int min1 = numbers[0];
@ricky-lim
ricky-lim / main.rs
Created February 28, 2023 20:11
exponentiate a list of numbers
fn main() {
let mut v = vec![1, 2, 3, 4, 5];
let exp = 2;
for num in &mut v {
*num = i32::pow(*num, exp);
}
println!("{:?}", v);
}
{"measurement": {"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2}, "species": "setosa"}
{"measurement": {"sepal_length": 4.9, "sepal_width": 3.0, "petal_length": 1.4, "petal_width": 0.2}, "species": "setosa"}
{"measurement": {"sepal_length": 4.7, "sepal_width": 3.2, "petal_length": 1.3, "petal_width": 0.2}, "species": "setosa"}
{"measurement": {"sepal_length": 4.6, "sepal_width": 3.1, "petal_length": 1.5, "petal_width": 0.2}, "species": "setosa"}
{"measurement": {"sepal_length": 5.0, "sepal_width": 3.6, "petal_length": 1.4, "petal_width": 0.2}, "species": "setosa"}
{"measurement": {"sepal_length": 5.4, "sepal_width": 3.9, "petal_length": 1.7, "petal_width": 0.4}, "species": "setosa"}
{"measurement": {"sepal_length": 4.6, "sepal_width": 3.4, "petal_length": 1.4, "petal_width": 0.3}, "species": "setosa"}
{"measurement": {"sepal_length": 5.0, "sepal_width": 3.4, "petal_length": 1.5, "petal_width": 0.2}, "species": "setosa"}
{"measurement": {"sepal_length": 4.4, "sepal_width": 2.9