Skip to content

Instantly share code, notes, and snippets.

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication9;
/**
*
* @author f023507i
@efarioli
efarioli / Program.cs
Created February 6, 2020 19:50
Find all Anagrams. Given a very long list of words: find all the sets of anagrams, print each set, print the total quantity of sets and print the total quantity of words.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace task01
@efarioli
efarioli / Validate US Telephone Numbers
Created December 5, 2016 00:18
Return true if the passed string is a valid US phone number. The user may fill out the form field any way they choose as long as it is a valid US number. The following are examples of valid formats for US numbers (refer to the tests below for other variants): 555-555-5555 ||| (555)555-5555 ||| (555) 555-5555 ||| 555 555 5555 ||| 5555555555 ||| 1…
//javascript
function telephoneCheck(str) {
if (!balancedParens(str)){
return false;
}
//remove whitespace
var newStr = str.replace(/\s/g, '');
@efarioli
efarioli / Seek and Destroy
Created November 27, 2016 12:56
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
//javascript
function destroyer(arr) {
var argLen = arguments.length;
console.log(argLen);
var arr2 = [];
if (argLen <= 1) {
return arr;
}
for (var i = 1; i < argLen; i++) {
@efarioli
efarioli / Return Largest Numbers in Arrays
Created November 26, 2016 23:04
Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.
//javascript
function largestOfOne(arr) {
var largest = 0;
console.log(arr.length);
for (i = 0; i < arr.length; i++) {
console.log(i);
if (largest < arr[i]) {
largest = arr[i];
}
@efarioli
efarioli / Caesars Cipher
Last active November 26, 2016 23:05
One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher
//javascript
/*One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount.
A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.
Write a function which takes a ROT13 encoded string as input and returns a decoded string.
All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
*/