- 1995
- Brenden Eich, 2 weeks etc.
- Open Node
- Try Basic Math (1 + 2, etc);
- Show strings
- Variable assignment
- Calling methods on variables
- Array declaration (note that you can put anything there)
| var toAsciiGrayscale = function(luminence) { | |
| var chars = " .:-=+*#%@"; | |
| var index = Math.floor((1 - luminence) * 0.99 * chars.length); | |
| return chars[index]; | |
| }; | |
| var printBitmap = function(bitmap) { | |
| return bitmap.map(function(row) { | |
| return row.map(toAsciiGrayscale).join(''); | |
| }).join('\n'); |
| def potential_parents(x): | |
| S = { 2*x } | |
| if (x - 1) % 3 is 0: | |
| S.add( (x-1) // 3) | |
| return S | |
| def grid_print(elements): | |
| output = '' | |
| for i in range(200): | |
| if i in elements: |
| # Calculates the run length of a sequence in string starting at startIndex | |
| def run_length(string, startIndex): | |
| offset = 1 | |
| while startIndex + offset < len(string) and string[startIndex + offset] == string[startIndex]: | |
| offset += 1 | |
| return offset | |
| def encode_binary(binary): | |
| offset = 0 | |
| encoded = '' |
| var keyMap = { | |
| 2: 'abc', | |
| 3: 'def', | |
| 4: 'ghi', | |
| 5: 'jkl', | |
| 6: 'mno', | |
| 7: 'pqrs', | |
| 8: 'tuv', | |
| 9: 'wxyz', | |
| 0: ' ' |
| import sys | |
| from math import floor as F, ceil as C | |
| w, h = [int(i) for i in input().split()] | |
| n = int(input()) # maximum number of turns before game over. | |
| x0, y0 = [int(i) for i in input().split()] | |
| xMin = 0 | |
| xMax = w - 1 |
| def insertIntoTrie(trie, word): | |
| if len(word) is 0: | |
| return trie | |
| if word[0] not in trie: | |
| trie[word[0]] = { } | |
| trie[word[0]] = insertIntoTrie(trie[word[0]], word[1:]) | |
| return trie |
| var toothSvg = function(position, radius) { | |
| radius = radius || 10; | |
| return '<circle fill="black" r="' + radius + '" cx="' + position.x + '" cy="' + position.y + '" />'; | |
| }; | |
| var bite = function(biteCenter, biteAngle) { | |
| var biteRadius = 20; | |
| var biteAngleOffset = 40; | |
| // convert to radius |
| #!/bin/bash | |
| # Templates a file with a given properties file | |
| template () { | |
| # $1 is the template file | |
| # $2 is the properties file | |
| # first, we convert the properties into a list of SED replacements. This regex is awful, but essentially does this: | |
| # A line like name=chip becomes a sed command s/${name}/chip/g for replacing "variables" with a particular value | |
| touch sed_commands.txt |
| def insertions(two_digit, one_digit): | |
| two_digit_str = str(two_digit) | |
| one_digit_str = str(one_digit) | |
| # yield all permutations, so it "feels" like an iterable | |
| yield one_digit_str + two_digit_str | |
| yield two_digit_str[0] + one_digit_str + two_digit_str[1] | |
| yield two_digit_str + one_digit_str | |
| def printOneSolution(solution): |