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
question = """ | |
Sum the odd-square numbers less than a given integer n. | |
Example: | |
> oddSquareSum(1) | |
> 0 | |
> oddSquareSum(2) | |
> 1 | |
> oddSquareSum(9) |
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
question = """ | |
Spreadsheet programs often use the A1 Reference Style to refer | |
to columns. Given a column name in this style, return its column number. | |
Eexcel_columnamples of column names to their numbers: | |
A -> 1 | |
B -> 2 | |
C -> 3 | |
// etc |
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
question = """ | |
You are given a list of positive integers which represents some range of | |
integers which has been truncated. Find the missing bits, insert ellipses | |
to show that that part has been truncated, and print it. | |
If the consecutive values differ by exactly two, then insert | |
the missing value. | |
Examples: | |
> missingBits([1,2,3,4,20,21,22,23]) |
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
question = """ | |
Given an array of integers arr and an integer n, return a | |
subarray of arr of length n where the sum is the largest. | |
Make sure you maintain the order of the original array, and | |
if n is greater than arr.length, you can choose what you | |
want to return. | |
Example: | |
> maxSubarray([-4,2,-5,1,2,3,6,-5,1], 4) |
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
sub replaceZeros($) { | |
$out_str = $_[0]; | |
$out_str =~ s/(0+)/length($1)/ge; | |
printf("$out_str\n"); | |
} | |
replaceZeros("1234500"); | |
replaceZeros('1234500362000440'); | |
replaceZeros('123450036200044'); | |
replaceZeros('000000000000'); |
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
question = """ | |
Given a string of any length which contains only digits from 0 to 9, | |
replace each consecutive run of the digit 0 with its length. | |
Example: | |
> replaceZeros('1234500362000440') | |
> 1234523623441 | |
> replaceZeros('123450036200044') |
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
START: LDY #00 ; start loop at 0 | |
LOOP: LDA $0800,Y ; load Y-th character | |
BEQ _END ; stop loop if NULL found | |
TRY_A: CMP #61 ; compare to 'a' | |
BNE _TRY_E | |
JSR _VOWEL ; found a vowel | |
INY ; next character | |
JMP _LOOP | |
TRY_E: CMP #65 ; compare to 'e' | |
BNE _TRY_I |
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
question = """ | |
Given a string, make every consonant after a vowel | |
uppercase. Can you do this with and without regex? | |
Example: | |
> capitalAfterVowel("hello world") | |
> "heLlo WoRld" | |
> capitalAfterVowel("xaabeuekadii") |
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
question = """ | |
Given a list of strings arr, and a max size n, return a new list where the | |
strings (from left to right) are joined together with a space, so that each | |
new string is less than or equal to the max size. | |
Examples: | |
> combineStrings(["a", "b", "c", "d", "e", "f", "g"], 5) | |
> ["a b c", "d e f", "g"] |
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
question = """ | |
Let's say you have n doors that start out as closed. With the | |
first pass across the doors, you toggle every door open. With | |
the second pass, you toggle every second door. With the third, | |
every third door, and so on. Write a function that takes in an | |
integer numberOfPasses, and returns how many doors are open after | |
the number of passes. Thanks Max for inspiring this question! | |
Example: |
NewerOlder