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
bool almostIncreasingSequence(std::vector<int> sequence) { | |
auto begin = std::begin(sequence); | |
auto end = std::end(sequence); | |
if (sequence.size() < 2) { | |
// outside constrains | |
return false; | |
} | |
bool has_skipped = false; |
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
auto consecutive_array(auto input) { | |
auto begin = std::begin(input); | |
auto end = std::end(input); | |
std::sort(begin, end); | |
begin = std::begin(input); | |
end = std::end(input); | |
decltype(*begin) required; |
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
int shapeArea(int n) { | |
int maxLen = ((n - 1) * 2) + 1; | |
int area = 0; | |
for (int i = maxLen - 2; i > 0;) { | |
area += i * 2; | |
i -= 2; | |
} | |
area += maxLen; |
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
int adjacentElementsProduct(std::vector<int> inputArray) { | |
auto begin = std::begin(inputArray); | |
auto end = std::end(inputArray); | |
if (inputArray.size() < 2) { | |
// what do we return in this instance?? | |
// is the input gauranteed to be at least 2 elements? | |
return 0; | |
} | |
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
bool checkPalindrome(std::string inputString) { | |
auto begin = inputString.begin(); | |
auto end = inputString.end(); | |
auto rbegin = inputString.rbegin(); | |
for (; begin != end;) { | |
if (*begin != *rbegin) { | |
return false; | |
} |
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
; in: r0, r1 | |
; out: r0, r1 | |
2reg_swap: | |
add r0, r1 | |
sub r1, r0, r1 | |
sub r0, r0, r1 | |
bx lr | |
; in: r0, r1 | |
; out: r0, r1 |
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
#!/bin/bash | |
if [ "$#" -eq 0 ]; then | |
echo "no parameter passed, must pass image to upload" | |
exit 1 | |
fi | |
FILE=$1 | |
POSTURL="http://bacs.bounceme.net/uploads/index.php" | |
COUNTER=0 |
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
(define golden-ratio | |
(/ (+ 1 (sqrt 5)) 2)) | |
(define (fibonacci n) | |
(/ (- (expt golden-ratio n) | |
(expt (- (/ 1 golden-ratio)) n)) | |
(sqrt 5))) |
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
/** | |
* Encodes a string into its base37 integral value | |
* | |
* @param str the string to encode | |
* @return the base37 value | |
*/ | |
public static long encodeb37(String str) { | |
String str1 = ""; | |
for (int i = 0; i < str.length(); i++) { | |
char c = str.charAt(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
fn base37_encode(text: String) -> u64 { | |
let mut hash = 0; | |
for ch in text.chars().take(12) { | |
let modifier = match ch { | |
'a'...'z' => 1 + (ch as u64 - 'a' as u64), | |
'A'...'Z' => 1 + (ch as u64 - 'A' as u64), | |
'0'...'9' => 33 + (ch as u64 - '0' as u64), | |
_ => 0, | |
}; |