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
| /** | |
| * Created by Kyle Long on 2/24/19. | |
| */ | |
| public class removeOdd { | |
| public static void main(String [] args){ | |
| System.out.println(removeForOdd(new int[]{2,4,6,7,8})); | |
| System.out.println(removeForOdd(new int[]{4,4,4})); | |
| System.out.println(removeForOdd(new int[]{1,2,3,4,5,6,7})); | |
| } |
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.*; | |
| /** | |
| * Created by kylel95 on 3/1/19. | |
| */ | |
| public class phonePad { | |
| public static void main(String [] args){ | |
| String s = "123456"; | |
| perm1(makeString(s)); | |
| } |
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
| let nums = [] | |
| function squareCubeNums(num){ | |
| for(var i = 1; i <= num; i++){nums[i] = i;} | |
| //Check for perfect square && check for perfect cube | |
| nums = nums.filter(number => Math.floor(Math.sqrt(number)) - Math.sqrt(number) == 0 && Math.pow(Math.round(Math.pow(number, 1/3)), 3) == number); | |
| console.log(nums); | |
| } | |
| squareCubeNums(64); |
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
| #Given an integer N, find the number of trailing zeroes | |
| # in the base 16 representation of the factorial of N. | |
| def trailing(number) | |
| num = factorial(number).to_s(16) | |
| length = num.length | |
| chars = num.split('') | |
| count = 0 | |
| for c in num.split('').reverse() | |
| if(c == '0') | |
| count += 1 |
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.HashMap; | |
| /** | |
| * Created by kylel95 on 5/21/19. | |
| * Find the last non-repeating character in a given string. | |
| */ | |
| public class lastUnique { | |
| public static void main(String [] args){ | |
| String s = "candy canes do taste yummy"; |
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
| =begin | |
| Integer dvision for a / b | |
| @param a first number | |
| @param b second number | |
| @return a / b | |
| =end | |
| def divide(a, b) | |
| sign = (a < 0) ^ (b < 0) ? -1 : 1 | |
| a = a.abs | |
| b = b.abs |
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
| #Given an array of integers, find the maximum range between two elements in the array. | |
| def maxRange(arr) | |
| return arr.max.abs - arr.min.abs | |
| end | |
| puts maxRange([2,2,1,3]) #2 | |
| puts maxRange([0]) #0 | |
| puts maxRange([4,3,5,7,1,7,7,6]) #6 |
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
| =begin | |
| Converts hex codes to rgb | |
| https://www.mathsisfun.com/hexadecimals.html | |
| supports hashtag and non hashtag | |
| @param s string to be converted to RGB | |
| @return RGB representation of a string | |
| =end | |
| def hex_to_rgb(s) | |
| if s[0] == "#" #removes '#' from evalutation | |
| s = s[1..s.length] |
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
| public class Growth{ | |
| /** | |
| n!,2n,2n^2, 5nlogn,20n,10n | |
| */ | |
| public static void main(String [] args){ | |
| long fact, twon, twon2, fivenlogn, twentyn, tenn; | |
| for(long i = 0; i < 20; i++){ | |
| fact = fact(i); | |
| twon = (long)Math.pow(2, i); | |
| twon2 = 2 * (long)Math.pow(i, 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.io.*; | |
| import java.nio.ByteBuffer; | |
| public class BinaryParser { | |
| /** | |
| * byte array Byte buffer | |
| * @param args | |
| */ | |
| public static void main(String[] args) { | |
| try { |