This file contains hidden or 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
| { | |
| Request scope | |
| { | |
| Page scope 1 | |
| } | |
| { | |
| Page scope 2 | |
| } |
This file contains hidden or 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
| package com.ffbit.fun.array; | |
| import org.junit.Test; | |
| import org.junit.runner.RunWith; | |
| import org.junit.runners.Parameterized; | |
| import java.util.Arrays; | |
| import java.util.Collection; | |
| import static org.hamcrest.CoreMatchers.is; |
This file contains hidden or 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
| package com.ffbit.collections; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.junit.Assert.assertThat; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import org.junit.Before; | |
| import org.junit.Test; |
This file contains hidden or 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
| package com.ffbit.collections; | |
| import static org.hamcrest.CoreMatchers.hasItems; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.hamcrest.CoreMatchers.not; | |
| import static org.junit.Assert.assertThat; | |
| import java.util.ArrayList; | |
| import java.util.Collection; | |
| import java.util.Collections; |
This file contains hidden or 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 org.junit.runner.RunWith | |
| import org.scalatest.junit.JUnitRunner | |
| import org.scalatest.FunSuite | |
| import scala.annotation.tailrec | |
| @RunWith(classOf[JUnitRunner]) | |
| class BinarySearchSuite extends FunSuite { | |
| trait TestBinarySearch { | |
| val v = Vector(1, 2, 4) |
This file contains hidden or 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 binary_search(a, needle) | |
| start = 0 | |
| finish = a.size - 1 | |
| while start <= finish do | |
| middle = start + (finish - start) / 2 | |
| if a[middle] == needle | |
| return middle | |
| elsif a[middle] < needle |
This file contains hidden or 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 reverse(a) | |
| half = a.size / 2 | |
| (0...half).each do |i| | |
| j = a.size - i - 1 | |
| a[i], a[j] = a[j], a[i] | |
| end | |
| a | |
| end | |
| reverse([1, 2]) |
This file contains hidden or 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.util.ArrayList; | |
| import java.util.List; | |
| public class Main { | |
| public static void main(String... args) { | |
| // Two identical list of fruit | |
| final List<String> fruit = getFruit(); | |
| final List<String> fruit2 = getFruit(); |
This file contains hidden or 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
| package org.test; | |
| import java.io.File; | |
| import java.net.MalformedURLException; | |
| import java.net.URL; | |
| import java.net.URLClassLoader; | |
| import java.util.Locale; | |
| import java.util.MissingResourceException; | |
| import java.util.ResourceBundle; |
This file contains hidden or 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
| leaderboard = ["ERC", "AMY", "BOB", "AAA", "STU"] | |
| [winner, others..., loser] = leaderboard | |
| console.log """ | |
| First place: #{winner}. | |
| Last place: #{loser}. | |
| """ |