Hmm...
using System.Collections.Generic; using System.Diagnostics; using System; public class TowerOfHanoi { public static int Tower(int numOfDisks) { return numOfDisks; } public static int Tower(int n, string source, string aux, string dest, Dictionary<int, int> cache) { int count = 0; if(n == 1) { cache.Add(count++,count++); return 1; } Tower(n-1, source, dest, aux, cache); cache.Add(count++,count++); Tower(n-1, aux, source, dest, cache); return (int)Math.Pow(2,n)-1; } }
- using System.Collections.Generic;
- using System.Diagnostics;
- using System;
- public class TowerOfHanoi
- {
- public static int Tower(int numOfDisks)
- {
return 0;- return numOfDisks;
- }
private static int Tower(int n, string source, string aux, string dest, Dictionary<int, int> cache)- public static int Tower(int n, string source, string aux, string dest, Dictionary<int, int> cache)
- {
return 0;- int count = 0;
- if(n == 1)
- {
- cache.Add(count++,count++);
- return 1;
- }
- Tower(n-1, source, dest, aux, cache);
- cache.Add(count++,count++);
- Tower(n-1, aux, source, dest, cache);
- return (int)Math.Pow(2,n)-1;
- }
- }
function removeEveryThird(str) { var returnString = ''; var words = str.split(' '); var counter = 0; for (var i = 0; i < words.length; i++) { var word = words[i]; counter = 0; for (var j = 0; j < word.length; j++) { if (counter !== 3) { returnString += word.charAt(j); } counter++; } } return returnString; }
function removeEveryThird(str) {// Remove the third character from every work in the string// using a zero based indexreturn 'heloword';- function removeEveryThird(str)
- {
- var returnString = '';
- var words = str.split(' ');
- var counter = 0;
- for (var i = 0; i < words.length; i++)
- {
- var word = words[i];
- counter = 0;
- for (var j = 0; j < word.length; j++)
- {
- if (counter !== 3)
- {
- returnString += word.charAt(j);
- }
- counter++;
- }
- }
- return returnString;
- }
function prime_checker(n) { if(n <= 1) { return false; } for(var i = 2; i <= Math.sqrt(n); i++) { if(n%i == 0) { return false; } } return true; }
function prime_checker (n) {// Write a javascript function to check if N is a prime number- function prime_checker(n)
- {
- if(n <= 1)
- {
- return false;
- }
- for(var i = 2; i <= Math.sqrt(n); i++)
- {
- if(n%i == 0)
- {
- return false;
- }
- }
- return true;
- }
public class Adder { public static int AddAllContent(int[] numbersToAdd) { int sum = 0; int index = 0; while(index != numbersToAdd.length) { sum+= numbersToAdd[index]; index++; } return sum; } }
public class Adder {- public class Adder
- {
public static int AddAllContent(int[] numbersToAdd) {- public static int AddAllContent(int[] numbersToAdd)
- {
- int sum = 0;
for (int i : numbersToAdd)sum += i;return sum;- int index = 0;
- while(index != numbersToAdd.length)
- {
- sum+= numbersToAdd[index];
- index++;
- }
- return sum;
- }
- }
import java.util.stream.IntStream; public class Adder { public static int AddAllContent(int[] numbersToAdd) { int sum = IntStream.of(numbersToAdd).sum(); return sum; } }
public class Adder {public static int AddAllContent(int[] numbersToAdd) {int sum = 0;for (int i : numbersToAdd)sum += i;return sum;- import java.util.stream.IntStream;
- public class Adder
- {
- public static int AddAllContent(int[] numbersToAdd)
- {
- int sum = IntStream.of(numbersToAdd).sum();
- return sum;
- }
- }