static returnhundred(){ ([66702978501828] as Random).nextInt() }
public class Solution{public static int returnhundred(){return new java.util.Random(66702978501828L).nextInt();}}- static returnhundred(){
- ([66702978501828] as Random).nextInt()
- }
class Test { @org.junit.jupiter.api.Test void assertEquals() { org.junit.jupiter.api.Assertions .assertEquals(solution.returnhundred(), 100); } }
public class Test {- class Test {
- @org.junit.jupiter.api.Test
public void assertEquals() {- void assertEquals() {
- org.junit.jupiter.api.Assertions
.assertEquals(Solution.returnhundred(), 100);- .assertEquals(solution.returnhundred(), 100);
- }
- }
import static java.util.stream.Collectors.toMap; import static java.util.stream.IntStream.range; import static java.util.function.Function.identity; import static java.util.Arrays.stream; class Solution { public static int similarPairs(String[] words) { return stream(words) .collect(toMap(identity(), x -> 1, Integer::sum)) .values() .stream() .mapToInt(x -> x - 1) .sum(); } }
import org.junit.jupiter.api.Test;import java.util.HashSet;import java.util.Set;- import static java.util.stream.Collectors.toMap;
- import static java.util.stream.IntStream.range;
- import static java.util.function.Function.identity;
- import static java.util.Arrays.stream;
- class Solution {
- public static int similarPairs(String[] words) {
int num=0;Set<String> seenWords = new HashSet<>();for (String word: words){if (seenWords.contains(word)){num++;}seenWords.add(word);}return num;- return stream(words)
- .collect(toMap(identity(), x -> 1, Integer::sum))
- .values()
- .stream()
- .mapToInt(x -> x - 1)
- .sum();
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testSomething() { Solution aaa = new Solution(); String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; String[] cars2 = {"Volvo", "Volvo", "Volvo", "Mazda"}; assertEquals("actual", "actual"); assertEquals(aaa.similarPairs(cars), 0); assertEquals(aaa.similarPairs(cars2), 2); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void testSomething() {
Solution aaa = new Solution();String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};- Solution aaa = new Solution();
- String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
- String[] cars2 = {"Volvo", "Volvo", "Volvo", "Mazda"};
- assertEquals("actual", "actual");
- assertEquals(aaa.similarPairs(cars), 0);
- assertEquals(aaa.similarPairs(cars2), 2);
- }
- }
import java.util.Arrays; public class Solution { public static int addArr(int[] arr){ return Arrays.stream(arr).sum(); } }
function addArr(arr){- import java.util.Arrays;
if(arr.length === 0) return nulllet final = 0arr.forEach(num => {final += num})return final- public class Solution {
- public static int addArr(int[] arr){
- return Arrays.stream(arr).sum();
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; public class SolutionTest { @Test public void test() { assertEquals(Solution.addArr(new int[]{1, 2, 3, 4, 5}), 15); assertEquals(Solution.addArr(new int[]{1, 100}), 101); assertEquals(Solution.addArr(new int[0]), 0); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
const chai = require("chai");const assert = chai.assert;describe("Solution", function() {it("should test for something", function() {assert.strictEqual(addArr([1, 2, 3, 4, 5]), 15);assert.strictEqual(addArr([1, 100]), 101)assert.strictEqual(addArr([]), null)});});- public class SolutionTest {
- @Test
- public void test() {
- assertEquals(Solution.addArr(new int[]{1, 2, 3, 4, 5}), 15);
- assertEquals(Solution.addArr(new int[]{1, 100}), 101);
- assertEquals(Solution.addArr(new int[0]), 0);
- }
- }
public class Solution{ public static int returnhundred(){ return new java.util.Random(66702978501828L).nextInt(); } }
fun returnhundred():Int = java.util.Random(66702978501828L).nextInt();- public class Solution{
- public static int returnhundred(){
- return new java.util.Random(66702978501828L).nextInt();
- }
- }
public class Test { @org.junit.jupiter.api.Test public void assertEquals() { org.junit.jupiter.api.Assertions .assertEquals(Solution.returnhundred(), 100); } }
import kotlin.test.Testimport kotlin.test.assertEquals- public class Test {
@Testfun assertEquals() {assertEquals(returnhundred(), 100);- @org.junit.jupiter.api.Test
- public void assertEquals() {
- org.junit.jupiter.api.Assertions
- .assertEquals(Solution.returnhundred(), 100);
- }
fun returnhundred():Int = java.util.Random(66702978501828L).nextInt();
function returnhundred() {return 'd'.charCodeAt();}- fun returnhundred():Int = java.util.Random(66702978501828L).nextInt();
import kotlin.test.Test import kotlin.test.assertEquals public class Test { @Test fun assertEquals() { assertEquals(returnhundred(), 100); } }
Test.assertEquals(returnhundred(),100)- import kotlin.test.Test
- import kotlin.test.assertEquals
- public class Test {
- @Test
- fun assertEquals() {
- assertEquals(returnhundred(), 100);
- }
- }