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
public IEnumerator<IScheminType> GetEnumerator () | |
{ | |
var c = Cdr(); | |
if (!this.Empty) | |
yield return Car(); | |
c = Cdr(); | |
while (!c.Empty || c.quoted) { | |
yield return c.Car(); |
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
this.Empty = 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
(define (fib n) | |
(fib-iter 1 0 n)) | |
(define (fib-iter a b count) | |
(if (= count 0) | |
b | |
(fib-iter (+ a b) a (- count 1)))) | |
(define fibs '()) |
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-macro (do init test . expr) | |
(let ((bindings (map (lambda (x) (cons (car x) (list (cadr x)))) init)) | |
(steps (map (lambda (x) (if (< 2 (length x)) (caddr x) (car x))) init)) | |
(condition (car test)) | |
(endresult (cdr test)) | |
(loop-name (gensym))) | |
`(let ,loop-name ,bindings | |
(if (not ,condition) | |
(begin ,(car expr) ,(cons loop-name steps)) |
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-rewriter do | |
(lambda (form rename) | |
(let ((bindings (map (lambda (x) (cons (car x) (list (cadr x)))) (cadr form))) | |
(steps (map (lambda (x) (if (< 2 (length x)) (caddr x) (car x))) (cadr form))) | |
(condition (car (car (cddr form)))) | |
(endresult (cadr (car (cddr form)))) | |
(expr (cdddr form)) | |
(loop-name (gensym))) | |
`(,(rename 'let) ,loop-name ,bindings |
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
String Reduction (25 Points) | |
Given a string consisting of a,b and c's, we can perform the following operation: Take any two adjacent distinct characters and replace it with the third character. For example, if 'a' and 'c' are adjacent, they can replaced with 'b'. What is the smallest string which can result by applying this operation repeatedly? | |
Input: | |
The first line contains the number of test cases T. T test cases follow. Each case contains the string you start with. | |
Output: | |
Output T lines, one for each test case containing the smallest length of the resultant string after applying the operations optimally. | |
Constraints: |
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
def get_suffixes(str) | |
suffixes = Array.new(str.length) {|i| str[str.length - 1 - i, i + 1]} | |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Security.Cryptography; | |
using System.Text; | |
/* | |
* Example Usage: | |
* | |
* List<string> urls = new List<string> { "/img/something.jpg", "/img/nothing.jpg", "/static/res.html", "/script/test.js" }; |
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
using System; | |
using System.Collections.Generic; | |
namespace HashTable | |
{ | |
class HashTable<TKey, TValue> | |
{ | |
private int count; | |
private int size; | |
private List<KeyValuePair<TKey, TValue>>[] values; |
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
+[,+[-[>+>+<<-]>[<+>-]+>>++++++++[<-------->-]<-[<[-]>>>+[<+<+>>-]<[>+<-]<[<++> | |
>>+[<+<->>-]<[>+<-]]>[<]<]>>[-]<<<[[-]<[>>+>+<<<-]>>[<<+>>-]>>++++++++[<------- | |
->-]<->>++++[<++++++++>-]<-<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<<<<+>>>>++++[<++++++++ | |
>-]>-]<<-<-]>[<<<<[-]>>>>[<<<<->>>>-]]<<++++[<<++++++++>>-]<<-[>>+>+<<<-]>>[<<+ | |
>>-]+>>+++++[<----->-]<-[<[-]>>>+[<+<->>-]<[>+<-]<[<++>>>+[<+<+>>-]<[>+<-]]>[<] | |
<]>>[-]<<<[[-]<<[>>+>+<<<-]>>[<<+>>-]+>------------[<[-]>>>+[<+<->>-]<[>+<-]<[< | |
++>>>+[<+<+>>-]<[>+<-]]>[<]<]>>[-]<<<<<------------->>[[-]+++++[<<+++++>>-]<<+> | |
>]<[>++++[<<++++++++>>-]<-]>]<[-]++++++++[<++++++++>-]<+>]<.[-]+>>+<]>[[-]<]<] |