Skip to content

Instantly share code, notes, and snippets.

Avatar

mmloveaa mmloveaa

View GitHub Profile
@mmloveaa
mmloveaa / aogprotips.txt
Last active Apr 2, 2020
<AoGProTips> Synchronize animations with the Text-To-Speech
View aogprotips.txt
const callbacks = {
onTtsMark(markName) {
if (markName === ’START_ROAR’) {
beginRoaring();
} else if (markName === ’STOP_ROAR’) {
stopRoaring();
} else {
...
}
}
@mmloveaa
mmloveaa / 4-27 Seek and Destroy
Last active Dec 29, 2017
5/3 Seek and Destroy
View 4-27 Seek and Destroy
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.
function destroyer(arr) {
var myArguments = [];
for (var i=1; i<arguments.length; i++){
myArguments.push(arguments[i]);
}
return arr.filter(function(remove){
return myArguments.indexOf(remove) < 0;
@mmloveaa
mmloveaa / 4-26 Free Code Camp remove all falsy
Last active Jul 8, 2018
4-26 Free Code Camp remove all falsy
View 4-26 Free Code Camp remove all falsy
Remove all falsy values from an array.
Falsy values in JavaScript are false, null, 0, "", undefined, and NaN.
Remember to use Read-Search-Ask if you get stuck. Write your own code.
Here are some helpful links:
Boolean Objects
Array.filter()
@mmloveaa
mmloveaa / 4-19 Q2 Calculate Factorial
Last active Dec 29, 2017
4-19 Q2 Calculate Factorial
View 4-19 Q2 Calculate Factorial
Write a program that will read an integer N from STDIN and compute the factorial of N. The input to your program will contain many lines. On each line there will be exactly one integer. Your program should print the factorial of each integer in a separate line. Your program should terminate when it reads a number that is not positive.
1 <= N <= 15
Sample Input
1
2
3
-1
Sample Output
@mmloveaa
mmloveaa / 4-23 Valid Flag solution
Created Apr 23, 2016
4-23 Valid Flag solution
View 4-23 Valid Flag solution
if(validRow(arrayOfFlagObjects[0].flag)===true && validNeighbors(arrayOfFlagObjects[0].flag)===true){
console.log("YES");
}else {
console.log("NO");
}
// Solution 1
process.stdin.resume();
@mmloveaa
mmloveaa / 4-23 Valid Flag Question
Last active Apr 23, 2016
4-23 Valid Flag Question
View 4-23 Valid Flag Question
According to a new ISO standard, the flag of every country should have a checkered pattern n × m. Furthermore, the pattern should be a stripe pattern:
each row should contain squares of the same color.
the colors of adjacent rows should be different.
HackerLand's government has asked you to find out if their flag meets the new ISO standard.
Input
The first line contains an integer, T, the number of test cases to follow.
For each test case, the first line contains two space separated integers, N and M, where N is the number of rows and M is the number of columns in the flag. N lines follow, each line containing a string of length M. Each character of the string is a digit, i.e., a number in the range [0, 9]. Each digit in [0, 9] represents a unique color.
Output
View 4-19 Q3 Valid Flag
According to a new ISO standard, the flag of every country should have a checkered pattern n × m. Furthermore, the pattern should be a stripe pattern:
each row should contain squares of the same color.
the colors of adjacent rows should be different.
HackerLand's government has asked you to find out if their flag meets the new ISO standard.
Input
The first line contains an integer, T, the number of test cases to follow.
For each test case, the first line contains two space separated integers, N and M, where N is the number of rows and M is the number of columns in the flag. N lines follow, each line containing a string of length M. Each character of the string is a digit, i.e., a number in the range [0, 9]. Each digit in [0, 9] represents a unique color.
Output
@mmloveaa
mmloveaa / 4-19 -Q4 Sherlock and The Beast
Last active Apr 25, 2016
4-19 -Q4 Sherlock and The Beast
View 4-19 -Q4 Sherlock and The Beast
Sherlock Holmes and his dear friend Dr. Watson are working on an urgent problem. Watson had earlier learned through his "special relationship" contacts at MI6 that that the CIA has lately been facing weird problems with their supercomputer, 'The Beast'. Then, Sherlock received a note from Professor Moriarty, his archenemy, boasting that he has infected 'The Beast' with a virus.
Now, all of Sherlock's past efforts to subdue Moriarty had been in vain, but the note gave him new hope to finally triumph over his nemesis. You see, the note had been written on a piece of paper previously sat on Moriaty's desk under another piece of paper. Unbeknownst to anyone but the intrepid Sherlock Holmes, it had an impression of a number N on it. After following up with more clues from his past experience with Moriarty, Sherlock figured out that the key to remove the virus is the largest 'Decent' Number having N digits.
A 'Decent' Number has -
Only 3 and 5 as its digits.
The number of times 3 appears is divisible by 5.
The nu
@mmloveaa
mmloveaa / 4-19 Q5 - Closest Num
Last active Dec 29, 2017
4-19 Q5 - Closest Num
View 4-19 Q5 - Closest Num
Sorting is useful as a first step in many different operations. For example, searching for a specific elements is easier on a sorted data structure. But search is not the only task facilitated by an initial sort.
Given a list of unsorted numbers A={ a1, a2, a3,.. ,aN}, can you find the pair of numbers that has the smallest absolute difference between its elements? If there are multiple pairs that have the same absolute distance as the minimum, find them all.
Constraints
1 ≤ N ≤ 2x105
-107 ≤ x ≤ 107, where x ∈ array
No repetitions: ai≠ aj where 1 ≤ i < j ≤N
Input Format
@mmloveaa
mmloveaa / 4-19 - Q6 Modify Price
Last active Aug 23, 2020
4-19 - Q6 Modify Price
View 4-19 - Q6 Modify Price
Michael is a shop owner who keeps n list, L, of the name and sale price for each item in inventory. The store employees record the name and sale price of every item sold. Michael suspects his manager, Alex, of embezzling money and modifying the sale prices of some of the items. Write a program that finds the number of times Alex recorded an incorrect sale price.
Complete the verifyItems function provided in your editor so that it returns the number of incorrect sale prices recorded by Alex. It has 4 parameters:
origItems: An array of strings, where each element is an item name.
origPrices: An array of floating point numbers, where each element contains the original (correct) price of the item in the corresponding index of origItems.
items: An array of strings containing the name of the items with sales recorded by Alex.
prices: An array of floating point numbers, where each element contains the sale price recorded by Alex for the item in the corresponding index of items.
Note: Where required by the langua
You can’t perform that action at this time.