{{ message }}

Instantly share code, notes, and snippets.

Courtney Faulkner courtneyfaulkner

Created Sep 6, 2017
[BinaryTreeBottomView] #practice
View BinaryTreeBottomView.groovy
 class BinaryTreeBottomView { public static void main(String[] args) { Node root = new Node(20) root.left = new Node(8) root.right = new Node(22) root.left.left = new Node(5) root.left.right = new Node(3) root.right.left = new Node(4) root.right.right = new Node(25) root.left.right.left = new Node(10)
Created Sep 6, 2017
[ZigZag] #practice
View ZigZag.groovy
 class ZigZag { /* Example: Input: arr[] = {4, 3, 7, 8, 6, 2, 1} Output: arr[] = {3, 7, 4, 8, 2, 6, 1} Input: arr[] = {1, 4, 3, 2} Output: arr[] = {1, 4, 2, 3} */ static void main(String[] args) {
Created Sep 6, 2017
[SortedArrays] #practice
View SortedArrays.groovy
 class SortedArrays { /* For Example A = {10, 15, 25} B = {1, 5, 20, 30} The resulting arrays are: 10 20 10 20 25 30 10 30
Created Sep 6, 2017
[CountTriplets] #practice
View CountTriplets.groovy
 class CountTriplets { static void main(String[] args) { // (-2, 0, 1) and (-2, 0, 3) == 2 println "count=\${count([-2, 0, 1, 3] as int[], 2)}" // (1, 3, 4), (1, 3, 5), (1, 3, 7), (1, 4, 5) == 4 println "count=\${count([5, 1, 3, 4, 7] as int[], 12)}" // (2, 3, 4), (2, 3, 5), (2, 3, 8), (2, 4, 5), (3, 4, 5) == 5 println "count=\${count([9, 5, 3, 2, 4, 8] as int[], 14)}"
Created Sep 6, 2017
[FizzBuzz] #practice
View FizzBuzz.groovy
 class FizzBuzz { static void main(String[] args) { (1..100).each {println((it % 3 ? '' : 'fizz') + (it % 5 ? '' : 'buzz') ?: it)} } }
Created Sep 6, 2017
[Palindrome] #practice
View Palindrome.groovy
 import java.util.regex.Matcher class Palindrome { static void main(String[] args) { def stuff = 'This, stuff ala ffuts, is a sentence to isPalindrome (tacocat)!!ONE!1!' findPalindromes(stuff, true, true) println '==================' findPalindromes(stuff, true, true, true) println '==================' findPalindromes(stuff, false, true)
Created Sep 6, 2017
[ReverseArray] #practice
View ReverseArray.groovy
 class ReverseArray { /* Input: str = "a,b\$c" Output: str = "c,b\$a" Note that \$ and , are not moved anywhere. Only subsequence "abc" is reversed Input: str = "Ab,c,de!\$" Output: str = "ed,c,bA!\$" */
Created Sep 6, 2017
[ReverseNumberArray] #practice
View ReverseNumberArray.groovy
 class ReverseNumberArray { static void main(String[] args) { int[] arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] println "original: \$arr" println "reversed: \${reverse(arr, 0, arr.size() - 1)}" } static int[] reverse(int[] arr, int left, int right) { int temp = arr[right] arr[right] = arr[left]
Created Sep 6, 2017
[RPNCalculator] #practice
View RPNCalculator.groovy
 import java.util.*; class RpnCalculator { static void main(String[] args) { Calculator calc = new Calculator() '4 6 3 + 9 3 - * 1 1 ^ - +'.split(' ').each {calc.enter(it)} } } class Calculator {
Created Feb 14, 2017
Create a Jenkins instance in DDC
View 1_root-docker_start_master.sh
 #!/bin/bash # put this in root/docker_start_master.sh # Make files owned by jenkins (not root). This didn't work when done from the Dockerfile build. chown -R jenkins:jenkins /var/jenkins_home # Need to make sure docker.sock is in the "docker" group so that the "jenkins" user can use it: chown root:docker /var/run/docker.sock # Work-around a problem we're having with the container (running as a UCP service) not having DNS set-up: