Skip to content

Instantly share code, notes, and snippets.

View liavkoren's full-sized avatar

Liav liavkoren

View GitHub Profile
import fileinput
import sys
sys.setrecursionlimit(10000)
def solve(houses, transmitter_range):
houses.sort(reverse=True)
if len(houses) == 0:
return 0
"""
https://www.hackerrank.com/challenges/luck-balance
[(6, 3), (5, 1), (2, 1), (1, 1), (8, 1), (10, 0), (5, 0),]
"""
import fileinput
def data_stream():
#!/usr/bin/python
import fileinput
def data_stream():
for line in fileinput.input():
line = line.strip()
yield line
# A dictionary comprehension:
a = {num: Node(num) for num in range(1, 8)}
```
a now looks like:
{1: Node(data=1, next_node=None),
2: Node(data=2, next_node=None),
3: Node(data=3, next_node=None),
4: Node(data=4, next_node=None),
5: Node(data=5, next_node=None),
@liavkoren
liavkoren / gist:9053b059fb8578a58e26
Created December 1, 2014 18:36
jQuery code which runs twice
$( document ).ready(function() {
var replace_text_element_with_provinces = function(text_element) {
/*
Accepts a reference to a form's text element, builds a select
element populated with Canadian provinces and replaces the text
element with the select element.
*/
var provinces = $("#id_country").data("provinces");