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
# coding=utf-8 | |
import sys | |
from itertools import combinations | |
def number_pairs(nums, x): | |
return filter(lambda t: sum(t) == x, combinations(nums, 2)) | |
def display_number_pairs(pairs): |
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
# coding=utf-8 | |
import sys | |
import itertools | |
def main(): | |
with open(sys.argv[1], 'r') as f: | |
for line in f: | |
digits = map(lambda e: int(e), line.rstrip().split(",")) |
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
# coding=utf-8 | |
import sys | |
import string | |
# A : 1 | |
# B : 2 | |
# C : 3 | |
# ... | |
# Z : 26 | |
mapping = dict([(c, str(i + 1)) for i, c in enumerate(string.ascii_uppercase)]) |
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
# coding=utf-8 | |
import sys | |
def trailing_string(a, b): | |
if a.endswith(b): | |
return 1 | |
else: | |
return 0 |
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
# coding=utf-8 | |
import sys | |
class Point(object): | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
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
# coding=utf-8 | |
import sys | |
def get_first_non_repeated_character(s): | |
first_idx_of_non_repeated_character = list(map(lambda x: s.count(x), s)).index(1) | |
return s[first_idx_of_non_repeated_character] | |
def main(): |
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
# coding=utf-8 | |
import sys | |
def number_of_ones(s): | |
return bin(s).count("1") | |
def main(): | |
with open(sys.argv[1], "r") as f: |
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
# coding=utf-8 | |
import sys | |
def decimal_to_binary(n): | |
if n == 0: | |
return '0' | |
result = '' | |
while n > 0: | |
result = str(n % 2) + result |
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
# coding=utf-8 | |
import sys | |
coin_values = [1, 3, 5] | |
def main(): | |
with open(sys.argv[1], "r") as f: | |
for line in f: | |
line = line.rstrip() |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
"strconv" | |
) |