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
⎕IO←0 | |
intcode←{ | |
⍺←0 ⋄ i←⍺ ⋄ s←⍵ ⋄ instr←'0'(,⍣{4<≢⍺})⍕⍺⌷⍵ ⋄ opcode←⍎¯2↑instr ⋄ p_modes←⍎¨⌽3⍴instr | |
p←{mode←p_modes[⍵-1] | |
mode=0:s[i+⍵] | |
mode=1:i+⍵ | |
'ERR: Unknown parameter mode',mode} | |
i≥≢s:'ERR: no HALT opcode' |
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
⎕IO←0 | |
find←{ | |
⍺←0 | |
in←(⊃⍺⌷,(⍳100)∘.,⍳100) set ⊃0⌷⍵ | |
(⊃1⌷⍵)=0⌷intcode in:in[1 2] | |
(⍺+1)∇in (⊃1⌷⍵) | |
} | |
set←{s←⍵ ⋄ s[1 2]←⍺[0 1] ⋄ s} | |
intcode←{ | |
⍺←0 ⋄ s←state←⍵ |
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
keycode 8 = | |
keycode 9 = Escape NoSymbol Escape | |
keycode 10 = 1 exclam 1 exclam | |
keycode 11 = 2 at 2 at | |
keycode 12 = 3 numbersign 3 numbersign | |
keycode 13 = 4 dollar 4 dollar | |
keycode 14 = 5 percent 5 percent | |
keycode 15 = 6 asciicircum 6 asciicircum | |
keycode 16 = 7 ampersand 7 ampersand | |
keycode 17 = 8 asterisk 8 asterisk |
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 futures::{Async, Future, Poll}; | |
use tokio::io::{AsyncRead, AsyncWrite, Error, ReadHalf, WriteHalf}; | |
use tokio::net::TcpStream; | |
use warp::{path, Filter, Stream}; | |
struct Receiver { | |
rx: ReadHalf<TcpStream>, | |
} | |
impl Stream for Receiver { | |
type Item = String; |
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 futures::{Async, Poll}; | |
use redis; | |
use std::time::Duration; | |
use warp::{path, Filter, Stream}; | |
struct OutputStream { | |
con: redis::Connection, | |
} | |
impl OutputStream { |
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
(defun factorial (n) | |
(if (zerop n) 1 (* n (factorial (1- n))))) |
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() { | |
println!("{:?}", robot_paths(6)); | |
} | |
#[derive(Clone)] | |
struct Board { | |
squares: Vec<Vec<bool>>, | |
} | |
impl Board { |
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
/** | |
* | |
* A robot located at the top left corner of a 5x5 grid is trying to reach the | |
* bottom right corner. The robot can move either up, down, left, or right, | |
* but cannot visit the same spot twice. How many possible unique paths are | |
* there to the bottom right corner? | |
* | |
* make your solution work for a grid of any size. | |
* | |
*/ |
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
#[derive(Debug)] | |
pub struct LinkedList { | |
head: Option<Box<Node>>, | |
tail: Option<*mut Node>, | |
} | |
#[derive(Debug)] | |
struct Node { | |
value: i32, | |
next: Option<Box<Node>>, | |
} |
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
const LinkedList = function() { | |
this.head = null; | |
this.tail = null; | |
}; | |
LinkedList.prototype.addToTail = function(value) { | |
const newTail = { value, next: null }; | |
if (this.tail) { | |
this.tail.next = newTail; |