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
if ((num % 3 === 0) && (num % 5 === 0)){ | |
return 'fizzbuzz' | |
} else if (num % 3 === 0) { | |
return 'fizz' | |
} else if (num % 5 === 0) { | |
return 'buzz' | |
} else if (typeof num === 'number'){ | |
return num | |
} else { | |
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
do_fizzbuzz = fn | |
(0, 0, _) -> "Fizzbuzz" | |
(0, _, _) -> "Fizz" | |
(_, 0, _) -> "Buzz" | |
(_, _, a) -> a | |
end | |
fizzbuzz = fn(n) -> do_fizzbuzz.(rem(n,3), rem(n,5), n) end | |
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
func anchor(top: NSLayoutYAxisAnchor?, left: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, right: NSLayoutXAxisAnchor?, paddingTop: CGFloat, paddingLeft: CGFloat, paddingBottom: CGFloat, paddingRight: CGFloat, width: CGFloat, height: CGFloat) { | |
translatesAutoresizingMaskIntoConstraints = false | |
if let top = top { | |
self.topAnchor.constraint(equalTo: top, constant: paddingTop).isActive = true | |
} | |
if let left = left { | |
self.leftAnchor.constraint(equalTo: left, constant: paddingLeft).isActive = true | |
} |
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
"========================================================================= | |
" ~My vimrc~ | |
"========================================================================= | |
" | |
" Author: Ryan Huber | |
" | |
"------------------------------------------------------------------------- | |
" | |
set nocompatible | |
set t_Co=256 |
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
# /Users/rhuber/.config/tmuxinator/portal.yml | |
name: portal | |
root: ~/Code/portal | |
# Optional tmux socket | |
# socket_name: foo | |
# Note that the pre and post options have been deprecated and will be replaced by | |
# project hooks. |
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
/* | |
Given a binary array, find the maximum number of consecutive 1s in the array | |
Input: [1, 1, 0, 1, 1, 1] | |
Output: 3 | |
Note: | |
- the input array will contain 0 and 1 | |
- the length of the input array is a positive integer and will not exceed 10,000 | |
*/ |
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
func CountBits(x int) int { | |
numBits := 0 | |
for x != 0 { | |
numBits += x & 1 | |
x >>= 1 | |
} | |
return numBits | |
} |
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 main() { | |
for n in 0..22 { | |
println!("{}! = {}", n, factorial(n)); | |
} | |
} | |
fn factorial(n: isize) -> isize { | |
// base case | |
if n == 0 { | |
1 |
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
use std::io; | |
fn main() { | |
println!("Enter -1 to exit"); | |
loop { | |
let n = get_isize("Enter a number: "); | |
if n == -1 { | |
break; | |
} | |
println!("fibonacci of {} is {}", n, fibonacci(n)); |
OlderNewer