diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e5095d8..0000000 --- a/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -*.py[cod] -*~ - -# C extensions -*.so - -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox -nosetests.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# PyCharm -.idea \ No newline at end of file diff --git a/MY_BOOK/600_stars.png b/MY_BOOK/600_stars.png new file mode 100644 index 0000000..ca4a6bb Binary files /dev/null and b/MY_BOOK/600_stars.png differ diff --git a/book/book_second_edition.pdf b/MY_BOOK/ebook_pdf/book_second_edition.pdf similarity index 86% rename from book/book_second_edition.pdf rename to MY_BOOK/ebook_pdf/book_second_edition.pdf index e734a79..60ca209 100644 Binary files a/book/book_second_edition.pdf and b/MY_BOOK/ebook_pdf/book_second_edition.pdf differ diff --git a/MY_BOOK/ebook_src/abstract_structures/HashTableClass.py b/MY_BOOK/ebook_src/abstract_structures/HashTableClass.py new file mode 100755 index 0000000..2dad275 --- /dev/null +++ b/MY_BOOK/ebook_src/abstract_structures/HashTableClass.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +class HashTable(object): + def __init__(self, slots=10): + self.slots = slots + self.table = [] + self.create_table() + + def hash_key(self, value): + return hash(value)%self.slots + + def create_table(self): + for i in range(self.slots): + self.table.append([]) + + def add_item(self, value): + key = self.hash_key(value) + self.table[key].append(value) + + def print_table(self): + for key in range(len(self.table)): + print "Key is %s, value is %s." %(key, self.table[key]) + + def find_item(self, item): + pos = self.hash_key(item) + if item in self.table[pos]: + return True + else: + return False + +if __name__ == '__main__': + dic = HashTable(5) + for i in range(1, 40, 2): + dic.add_item(i) + + dic.print_table() + assert(dic.find_item(20) == False) + assert(dic.find_item(21) == True) diff --git a/MY_BOOK/ebook_src/abstract_structures/QueueClass.py b/MY_BOOK/ebook_src/abstract_structures/QueueClass.py new file mode 100755 index 0000000..eff7e91 --- /dev/null +++ b/MY_BOOK/ebook_src/abstract_structures/QueueClass.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# Time: 5 min + +__author__ = "bt3" + + +class Queue(object): + def __init__(self): + self.enq = [] + self.deq = [] + + def enqueue(self, item): + return self.enq.append(item) + + def deque(self): + if not self.deq: + while self.enq: + self.deq.append(self.enq.pop()) + return self.deq.pop() + + def peak(self): + if not self.deq: + while self.enq: + self.deq.append(self.enq.pop()) + if self.deq: + return self.deq[-1] + + def size(self): + return len(self.enq) + len(self.deq) + + def isempty(self): + return not (self.enq + self.deq) + +if __name__ == '__main__': + q = Queue() + for i in range(1,11): + q.enqueue(i) + print 'Size:', q.size() + print 'Is empty?', q.isempty() + print 'Peak: ', q.peak() + print + print 'Dequeuing...' + for i in range(10): + print q.deque() + print 'Size:', q.size() + print 'Is empty?', q.isempty() + print 'Peak: ', q.peak() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/abstract_structures/Stack.py b/MY_BOOK/ebook_src/abstract_structures/Stack.py new file mode 100755 index 0000000..ba36110 --- /dev/null +++ b/MY_BOOK/ebook_src/abstract_structures/Stack.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +class Stack(object): + def __init__(self): + self.content = [] + self.min_array = [] + self.min = float('inf') + + def push(self, value): + if value < self.min: + self.min = value + + self.content.append(value) + self.min_array.append(self.min) + + def pop(self): + if self.content: + value = self.content.pop() + self.min_array.pop() + if self.min_array: + self.min = self.min_array[-1] + return value + else: + return 'Empty List. ' + + def find_min(self): + if self.min_array: + return self.min_array[-1] + else: + return 'No min value for empty list.' + + def size(self): + return len(self.content) + + def isEmpty(self): + return not bool(self.content) + + def peek(self): + if self.content: + return self.content[-1] + else: + print('Stack is empty.') + + + def __repr__(self): + return '{}'.format(self.content) + + +if __name__ == '__main__': + q = Stack() + + for i in range(15,20): + q.push(i) + for i in range(10,5,-1): + q.push(i) + + + + for i in range(1, 13): + print q.pop(), q.find_min() \ No newline at end of file diff --git a/src/abstract_structures/__init__.py b/MY_BOOK/ebook_src/abstract_structures/__init__.py old mode 100644 new mode 100755 similarity index 100% rename from src/abstract_structures/__init__.py rename to MY_BOOK/ebook_src/abstract_structures/__init__.py diff --git a/src/abstract_structures/hash_tables/__init__.py b/MY_BOOK/ebook_src/abstract_structures/heap/__init__.py similarity index 100% rename from src/abstract_structures/hash_tables/__init__.py rename to MY_BOOK/ebook_src/abstract_structures/heap/__init__.py diff --git a/src/abstract_structures/heap/find_N_largest_smallest_items_seq.py b/MY_BOOK/ebook_src/abstract_structures/heap/find_N_largest_smallest_items_seq.py similarity index 94% rename from src/abstract_structures/heap/find_N_largest_smallest_items_seq.py rename to MY_BOOK/ebook_src/abstract_structures/heap/find_N_largest_smallest_items_seq.py index 11bde95..18042fe 100644 --- a/src/abstract_structures/heap/find_N_largest_smallest_items_seq.py +++ b/MY_BOOK/ebook_src/abstract_structures/heap/find_N_largest_smallest_items_seq.py @@ -1,13 +1,13 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" import heapq def find_N_largest_items_seq(seq, N): ''' find the N largest items in a sequence ''' return heapq.nlargest(N,seq) - + def find_N_smallest_items_seq(seq, N): ''' find the N smallest items in a sequence ''' return heapq.nsmallest(N, seq) @@ -18,7 +18,7 @@ def find_smallest_items_seq_heap(seq): ''' pops the smallest item, O(logN) ''' heapq.heapify(seq) return heapq.heappop(seq) - + def find_smallest_items_seq(seq): ''' if it is only one item, min() is faster ''' return min(seq) @@ -26,7 +26,7 @@ def find_smallest_items_seq(seq): def find_N_smallest_items_seq_sorted(seq, N): ''' N ~ len(seq), better sort instead''' return sorted(seq)[:N] - + def find_N_largest_items_seq_sorted(seq, N): ''' N ~ len(seq), better sort instead''' return sorted(seq)[len(seq)-N:] @@ -41,7 +41,7 @@ def test_find_N_largest_smallest_items_seq(module_name='this module'): assert(find_N_smallest_items_seq_sorted(seq, N) == [1,2,3]) assert(find_smallest_items_seq(seq) == 1) assert(find_smallest_items_seq_heap(seq) == 1) - + s = 'Tests in {name} have {con}!' print(s.format(name=module_name, con='passed')) diff --git a/src/abstract_structures/heap/heapify.py b/MY_BOOK/ebook_src/abstract_structures/heap/heapify.py similarity index 90% rename from src/abstract_structures/heap/heapify.py rename to MY_BOOK/ebook_src/abstract_structures/heap/heapify.py index 8c39c0e..aa1d86b 100644 --- a/src/abstract_structures/heap/heapify.py +++ b/MY_BOOK/ebook_src/abstract_structures/heap/heapify.py @@ -1,13 +1,13 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" class Heapify(object): def __init__(self, data=None): self.data = data or [] for i in range(len(data)//2, -1, -1): self.__max_heapify__(i) - + def __repr__(self): return '{}'.format(self.data) @@ -19,12 +19,12 @@ class Heapify(object): def right_child(self, i): return (i << 1) + 2 # +2 instead of +1 because it's 0-indexed. - + def __max_heapify__(self, i): largest = i left = self.left_child(i) right = self.right_child(i) - n = len(self.data) + n = len(self.data) largest = (left < n and self.data[left] > self.data[i]) and left or i largest = (right < n and self.data[right] > self.data[largest]) and right or largest if i is not largest: @@ -44,7 +44,6 @@ def test_Heapify(): l1 = [3, 2, 5, 1, 7, 8, 2] h = Heapify(l1) assert(h.extract_max() == 8) - print ("Tests Passed!") if __name__ == '__main__': test_Heapify() diff --git a/src/abstract_structures/heap/merge_sorted_seqs.py b/MY_BOOK/ebook_src/abstract_structures/heap/merge_sorted_seqs.py similarity index 76% rename from src/abstract_structures/heap/merge_sorted_seqs.py rename to MY_BOOK/ebook_src/abstract_structures/heap/merge_sorted_seqs.py index 861ca07..1d211b2 100644 --- a/src/abstract_structures/heap/merge_sorted_seqs.py +++ b/MY_BOOK/ebook_src/abstract_structures/heap/merge_sorted_seqs.py @@ -1,6 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" import heapq @@ -19,9 +19,7 @@ def test_merge_sorted_seq(module_name='this module'): seq2 = [2, 3, 4, 5, 6, 7, 9] seq3 = seq1 + seq2 assert(merge_sorted_seqseq1, seq2) == sorted(seq3)) - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) + if __name__ == '__main__': diff --git a/src/abstract_structures/heap/priority_queue.py b/MY_BOOK/ebook_src/abstract_structures/heap/priority_queue.py similarity index 86% rename from src/abstract_structures/heap/priority_queue.py rename to MY_BOOK/ebook_src/abstract_structures/heap/priority_queue.py index 605f78d..5aed910 100644 --- a/src/abstract_structures/heap/priority_queue.py +++ b/MY_BOOK/ebook_src/abstract_structures/heap/priority_queue.py @@ -1,6 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" import heapq @@ -9,11 +9,11 @@ class PriorityQueue(object): def __init__(self): self._queue = [] self._index = 0 # comparying same priority level - + def push(self, item, priority): - heapq.heappush(self._queue, (-priority, self._index, item)) + heapq.heappush(self._queue, (-priority, self._index, item)) self._index += 1 - + def pop(self): return heapq.heappop(self._queue)[-1] @@ -32,7 +32,6 @@ def test_PriorityQueue(): q.push(Item('test2'), 4) q.push(Item('test3'), 3) assert(str(q.pop()) == "Item('test2')") - print('Tests passed!'.center(20,'*')) if __name__ == '__main__': diff --git a/src/abstract_structures/heap/__init__.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/__init__.py similarity index 100% rename from src/abstract_structures/heap/__init__.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/__init__.py diff --git a/src/abstract_structures/linked_list/circular_ll.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/circular_ll.py similarity index 92% rename from src/abstract_structures/linked_list/circular_ll.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/circular_ll.py index 1330701..fdeb026 100644 --- a/src/abstract_structures/linked_list/circular_ll.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/circular_ll.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" ''' implement a function to see whether a linked list is circular. diff --git a/src/abstract_structures/linked_list/double_linked_list_fifo.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/double_linked_list_fifo.py similarity index 87% rename from src/abstract_structures/linked_list/double_linked_list_fifo.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/double_linked_list_fifo.py index 8546164..094b283 100644 --- a/src/abstract_structures/linked_list/double_linked_list_fifo.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/double_linked_list_fifo.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' Implement a double-linked list, which is very simple, we just need inherits from a Linked List Class and add an attribute for previous.''' @@ -18,7 +17,6 @@ class dNode(object): class dLinkList(LinkedListFIFO): - # print each node's value, starting from tail def printListInverse(self): node = self.tail while node: @@ -28,8 +26,6 @@ class dLinkList(LinkedListFIFO): except: break - # add a node in a position different from head, - # ie, in the end of the list def _add(self, value): self.length += 1 node = dNode(value) @@ -38,14 +34,12 @@ class dLinkList(LinkedListFIFO): node.previous = self.tail self.tail = node - # delete a node in some position def _delete(self, node): self.length -= 1 node.previous.pointer = node.pointer if not node.pointer: self.tail = node.previous - # locate node with some index def _find(self, index): node = self.head i = 0 @@ -66,11 +60,6 @@ class dLinkList(LinkedListFIFO): print('Node with index {} not found'.format(index)) - - - - - if __name__ == '__main__': from collections import Counter diff --git a/src/abstract_structures/linked_list/find_kth_from_the_end.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/find_kth_from_the_end.py similarity index 92% rename from src/abstract_structures/linked_list/find_kth_from_the_end.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/find_kth_from_the_end.py index 4937bc4..8fd0cba 100644 --- a/src/abstract_structures/linked_list/find_kth_from_the_end.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/find_kth_from_the_end.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" ''' Find the mth-to-last element of a linked list. One option is having two pointers, separated by m. P1 start at the roots diff --git a/src/abstract_structures/linked_list/linked_list_fifo.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/linked_list_fifo.py similarity index 81% rename from src/abstract_structures/linked_list/linked_list_fifo.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/linked_list_fifo.py index 1492795..9a983a9 100644 --- a/src/abstract_structures/linked_list/linked_list_fifo.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/linked_list_fifo.py @@ -1,15 +1,12 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' A class for a linked list that has the nodes in a FIFO order (such as a queue)''' from node import Node - - class LinkedListFIFO(object): def __init__(self): @@ -17,32 +14,24 @@ class LinkedListFIFO(object): self.length = 0 self.tail = None # this is different from ll lifo - - # print each node's value, starting from the head def _printList(self): node = self.head while node: print(node.value) node = node.pointer - # add a node in the first position - # read will never be changed again while not empty def _addFirst(self, value): self.length = 1 node = Node(value) self.head = node self.tail = node - # delete a node in the first position, ie - # when there is no previous node def _deleteFirst(self): self.length = 0 self.head = None self.tail = None print('The list is empty.') - # add a node in a position different from head, - # ie, in the end of the list def _add(self, value): self.length += 1 node = Node(value) @@ -50,15 +39,12 @@ class LinkedListFIFO(object): self.tail.pointer = node self.tail = node - - # add nodes in general def addNode(self, value): if not self.head: self._addFirst(value) else: self._add(value) - # locate node with some index def _find(self, index): prev = None node = self.head @@ -69,7 +55,6 @@ class LinkedListFIFO(object): i += 1 return node, prev, i - # delete nodes in general def deleteNode(self, index): if not self.head or not self.head.pointer: self._deleteFirst() @@ -87,9 +72,6 @@ class LinkedListFIFO(object): print('Node with index {} not found'.format(index)) - - - if __name__ == '__main__': ll = LinkedListFIFO() for i in range(1, 5): diff --git a/src/abstract_structures/linked_list/linked_list_lifo.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/linked_list_lifo.py similarity index 84% rename from src/abstract_structures/linked_list/linked_list_lifo.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/linked_list_lifo.py index 186af83..b75b621 100644 --- a/src/abstract_structures/linked_list/linked_list_lifo.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/linked_list_lifo.py @@ -1,9 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - +#!/usr/bin/env python +__author__ = "bt3" ''' Implement a unordered linked list, i.e. a LIFO linked list (like a stack) ''' @@ -16,15 +13,12 @@ class LinkedListLIFO(object): self.head = None self.length = 0 - - # print each node's value, starting from the head def _printList(self): node = self.head while node: print(node.value) node = node.pointer - # delete a node, given the previous node def _delete(self, prev, node): self.length -= 1 if not prev: @@ -32,14 +26,10 @@ class LinkedListLIFO(object): else: prev.pointer = node.pointer - # add a new node, pointing to the previous node - # in the head def _add(self, value): self.length += 1 self.head = Node(value, self.head) - - # locate node with some index def _find(self, index): prev = None node = self.head @@ -50,7 +40,6 @@ class LinkedListLIFO(object): i += 1 return node, prev, i - # locate node by value def _find_by_value(self, value): prev = None node = self.head @@ -63,8 +52,6 @@ class LinkedListLIFO(object): node = node.pointer return node, prev, found - - # find and delete a node by index def deleteNode(self, index): node, prev, i = self._find(index) if index == i: @@ -72,8 +59,6 @@ class LinkedListLIFO(object): else: print('Node with index {} not found'.format(index)) - - # find and delete a node by value def deleteNodeByValue(self, value): node, prev, found = self._find_by_value(value) if found: diff --git a/src/abstract_structures/linked_list/node.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/node.py similarity index 88% rename from src/abstract_structures/linked_list/node.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/node.py index 92908fb..0a2d459 100644 --- a/src/abstract_structures/linked_list/node.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/node.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" class Node(object): def __init__(self, value=None, pointer=None): diff --git a/src/abstract_structures/linked_list/part_linked_list.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/part_linked_list.py similarity index 92% rename from src/abstract_structures/linked_list/part_linked_list.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/part_linked_list.py index f38cd62..d178b27 100644 --- a/src/abstract_structures/linked_list/part_linked_list.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/part_linked_list.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' This function divides a linked list in a value, where everything smaller than this value goes to the front, and everything large goes to the back:''' diff --git a/src/abstract_structures/linked_list/sum_linked_list.py b/MY_BOOK/ebook_src/abstract_structures/linked_list/sum_linked_list.py similarity index 95% rename from src/abstract_structures/linked_list/sum_linked_list.py rename to MY_BOOK/ebook_src/abstract_structures/linked_list/sum_linked_list.py index 1c48c43..4cf14cb 100644 --- a/src/abstract_structures/linked_list/sum_linked_list.py +++ b/MY_BOOK/ebook_src/abstract_structures/linked_list/sum_linked_list.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' Supposing two linked lists representing numbers, such that in each of their nodes they carry one digit. This function sums the two numbers that these diff --git a/src/abstract_structures/linked_list/__init__.py b/MY_BOOK/ebook_src/abstract_structures/queues/__init__.py similarity index 100% rename from src/abstract_structures/linked_list/__init__.py rename to MY_BOOK/ebook_src/abstract_structures/queues/__init__.py diff --git a/src/abstract_structures/queues/animal_shelter.py b/MY_BOOK/ebook_src/abstract_structures/queues/animal_shelter.py similarity index 97% rename from src/abstract_structures/queues/animal_shelter.py rename to MY_BOOK/ebook_src/abstract_structures/queues/animal_shelter.py index 938b0c0..6208289 100644 --- a/src/abstract_structures/queues/animal_shelter.py +++ b/MY_BOOK/ebook_src/abstract_structures/queues/animal_shelter.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" """ A class for an animal shelter with two queues""" diff --git a/src/abstract_structures/queues/deque.py b/MY_BOOK/ebook_src/abstract_structures/queues/deque.py similarity index 92% rename from src/abstract_structures/queues/deque.py rename to MY_BOOK/ebook_src/abstract_structures/queues/deque.py index a6bb95a..ede3e53 100644 --- a/src/abstract_structures/queues/deque.py +++ b/MY_BOOK/ebook_src/abstract_structures/queues/deque.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' a class for a double ended queue (also inefficient) ''' diff --git a/src/abstract_structures/queues/linked_queue.py b/MY_BOOK/ebook_src/abstract_structures/queues/linked_queue.py similarity index 95% rename from src/abstract_structures/queues/linked_queue.py rename to MY_BOOK/ebook_src/abstract_structures/queues/linked_queue.py index 9df6d88..ca2aafd 100644 --- a/src/abstract_structures/queues/linked_queue.py +++ b/MY_BOOK/ebook_src/abstract_structures/queues/linked_queue.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' Queue acts as a container for nodes (objects) that are inserted and removed according FIFO''' diff --git a/src/abstract_structures/queues/palindrome_checker_with_deque.py b/MY_BOOK/ebook_src/abstract_structures/queues/palindrome_checker_with_deque.py similarity index 91% rename from src/abstract_structures/queues/palindrome_checker_with_deque.py rename to MY_BOOK/ebook_src/abstract_structures/queues/palindrome_checker_with_deque.py index ed8f591..af14321 100644 --- a/src/abstract_structures/queues/palindrome_checker_with_deque.py +++ b/MY_BOOK/ebook_src/abstract_structures/queues/palindrome_checker_with_deque.py @@ -1,17 +1,19 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" + + +""" Using our deque class and Python's deque class """ -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" import string import collections from deque import Deque + STRIP = string.whitespace + string.punctuation + "\"'" - -""" Using our deque class and Python's deque class """ def palindrome_checker_with_deque(str1): d1 = Deque() diff --git a/src/abstract_structures/queues/queue_from_two_stacks.py b/MY_BOOK/ebook_src/abstract_structures/queues/queue.py similarity index 86% rename from src/abstract_structures/queues/queue_from_two_stacks.py rename to MY_BOOK/ebook_src/abstract_structures/queues/queue.py index e1bf63e..f08c8b4 100644 --- a/src/abstract_structures/queues/queue_from_two_stacks.py +++ b/MY_BOOK/ebook_src/abstract_structures/queues/queue.py @@ -1,10 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -''' an example of a queue implemented from 2 stacks ''' +__author__ = "bt3" class Queue(object): @@ -13,17 +9,13 @@ class Queue(object): self.in_stack = [] self.out_stack = [] - - # basic methods def _transfer(self): while self.in_stack: self.out_stack.append(self.in_stack.pop()) - def enqueue(self, item): return self.in_stack.append(item) - def dequeue(self): if not self.out_stack: self._transfer() @@ -32,11 +24,9 @@ class Queue(object): else: return "Queue empty!" - def size(self): return len(self.in_stack) + len(self.out_stack) - def peek(self): if not self.out_stack: self._transfer() @@ -54,9 +44,7 @@ class Queue(object): return "Queue empty!" def isEmpty(self): - return not ((bool(self.in_stack) or bool(self.out_stack))) - - + return not (bool(self.in_stack) or bool(self.out_stack)) if __name__ == '__main__': diff --git a/src/abstract_structures/queues/__init__.py b/MY_BOOK/ebook_src/abstract_structures/stacks/__init__.py similarity index 100% rename from src/abstract_structures/queues/__init__.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/__init__.py diff --git a/src/abstract_structures/stacks/dec2bin_with_stack.py b/MY_BOOK/ebook_src/abstract_structures/stacks/dec2bin_with_stack.py similarity index 84% rename from src/abstract_structures/stacks/dec2bin_with_stack.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/dec2bin_with_stack.py index 4df7e09..31dc066 100644 --- a/src/abstract_structures/stacks/dec2bin_with_stack.py +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/dec2bin_with_stack.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" '''transform a decimal number to a binary number with a stack ''' diff --git a/src/abstract_structures/stacks/linked_stack.py b/MY_BOOK/ebook_src/abstract_structures/stacks/linked_stack.py similarity index 94% rename from src/abstract_structures/stacks/linked_stack.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/linked_stack.py index 1ccafb9..23a4ad6 100644 --- a/src/abstract_structures/stacks/linked_stack.py +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/linked_stack.py @@ -1,13 +1,11 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" """ A stack made of linked list""" - class Node(object): def __init__(self, value=None, pointer=None): self.value = value diff --git a/src/abstract_structures/stacks/reverse_string_with_stack.py b/MY_BOOK/ebook_src/abstract_structures/stacks/reverse_string_with_stack.py similarity index 81% rename from src/abstract_structures/stacks/reverse_string_with_stack.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/reverse_string_with_stack.py index 2a56573..014ab9b 100644 --- a/src/abstract_structures/stacks/reverse_string_with_stack.py +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/reverse_string_with_stack.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" ''' Uses a stack to reverse a string ''' diff --git a/src/abstract_structures/stacks/set_of_stacks.py b/MY_BOOK/ebook_src/abstract_structures/stacks/set_of_stacks.py similarity index 94% rename from src/abstract_structures/stacks/set_of_stacks.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/set_of_stacks.py index 9b1a38a..bfe5bde 100644 --- a/src/abstract_structures/stacks/set_of_stacks.py +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/set_of_stacks.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" """ define a class for a set of stacks """ diff --git a/MY_BOOK/ebook_src/abstract_structures/stacks/stack.py b/MY_BOOK/ebook_src/abstract_structures/stacks/stack.py new file mode 100755 index 0000000..869ecf3 --- /dev/null +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/stack.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# copy of the class ../Stack.py + +__author__ = "bt3" + + +class Stack(object): + def __init__(self): + self.content = [] + self.min_array = [] + self.min = float('inf') + + def push(self, value): + if value < self.min: + self.min = value + + self.content.append(value) + self.min_array.append(self.min) + + def pop(self): + if self.content: + value = self.content.pop() + self.min_array.pop() + if self.min_array: + self.min = self.min_array[-1] + return value + else: + return 'Empty List. ' + + def find_min(self): + if self.min_array: + return self.min_array[-1] + else: + return 'No min value for empty list.' + + def size(self): + return len(self.content) + + def isEmpty(self): + return not bool(self.content) + + def peek(self): + if self.content: + return self.content[-1] + else: + print('Stack is empty.') + + + def __repr__(self): + return '{}'.format(self.content) + + +if __name__ == '__main__': + q = Stack() + + for i in range(15,20): + q.push(i) + for i in range(10,5,-1): + q.push(i) + + + + for i in range(1, 13): + print q.pop(), q.find_min() \ No newline at end of file diff --git a/src/abstract_structures/stacks/stack_with_min.py b/MY_BOOK/ebook_src/abstract_structures/stacks/stack_with_min.py similarity index 95% rename from src/abstract_structures/stacks/stack_with_min.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/stack_with_min.py index ce64fc8..83a16ed 100644 --- a/src/abstract_structures/stacks/stack_with_min.py +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/stack_with_min.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' A stack with a minimum lookup ''' diff --git a/src/abstract_structures/stacks/towers_of_hanoi.py b/MY_BOOK/ebook_src/abstract_structures/stacks/towers_of_hanoi.py similarity index 88% rename from src/abstract_structures/stacks/towers_of_hanoi.py rename to MY_BOOK/ebook_src/abstract_structures/stacks/towers_of_hanoi.py index 5d90372..f424faa 100644 --- a/src/abstract_structures/stacks/towers_of_hanoi.py +++ b/MY_BOOK/ebook_src/abstract_structures/stacks/towers_of_hanoi.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" """ Implement the 'towers of hanoi'""" diff --git a/src/neat_builtin_examples/sets/bit_operations/bit_array.py b/MY_BOOK/ebook_src/bitwise_operations/bit_array.py old mode 100644 new mode 100755 similarity index 82% rename from src/neat_builtin_examples/sets/bit_operations/bit_array.py rename to MY_BOOK/ebook_src/bitwise_operations/bit_array.py index c5f8366..9e5aa46 --- a/src/neat_builtin_examples/sets/bit_operations/bit_array.py +++ b/MY_BOOK/ebook_src/bitwise_operations/bit_array.py @@ -1,17 +1,16 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python -''' Example of how to use a bit array in python as a "counter" dict: +__author__ = "bt3" +''' Example of how to use a bit array in python as a "counter" dict''' + +def print_dupl_ba(l1): + ''' >>> l1 = [0, 1, 2, 3, 4, 2, 6, 7, 8, 9] >>> print_dupl_ba(l1) 2 -''' + ''' - - -def print_dupl_ba(l1): bs = bytearray(10) for i in range(len(l1)): if i == l1[i]: @@ -22,9 +21,6 @@ def print_dupl_ba(l1): return None - - - if __name__ == '__main__': import doctest diff --git a/MY_BOOK/ebook_src/bitwise_operations/bitwise.txt b/MY_BOOK/ebook_src/bitwise_operations/bitwise.txt new file mode 100755 index 0000000..f55d9d1 --- /dev/null +++ b/MY_BOOK/ebook_src/bitwise_operations/bitwise.txt @@ -0,0 +1,33 @@ + BIT-WISE + ---------------------- + +1. To find a number: +11000101 is 2^0+2^2+2^6+2^7 = 197 + + +2. Left shifting: + 0010 1011 << 4 ---> 1011 000 + + +3. Right shifting: + 0010 1011 >> 4 ---> 0000 0010 + or it can be filled with the copy of the first bit, instead of 0: + 1011 0010 >> 4 ---> 1111 1011 + + +4. XOR can cancels out: +15 ^ 12 ^ 15 = 12 + + +5. 2^x: + left-shift 1 by x: + 0000 0001 << x + + so if x = 2, 2^2 = 4 -> 100 + + 0000 0001 << 2 ---> 0000 0100 + + +6. Is power of 2? + just do x&(x-1). + if 0 --> yes! diff --git a/MY_BOOK/ebook_src/bitwise_operations/clear_bits.py b/MY_BOOK/ebook_src/bitwise_operations/clear_bits.py new file mode 100755 index 0000000..5297b74 --- /dev/null +++ b/MY_BOOK/ebook_src/bitwise_operations/clear_bits.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' Clear a bit in a binary number. + Like the reverse of set bit: + 1) first create a number filled of 1s, + with 0 at i (can create 0001000 and ~) + 2) AND the number so it clears the ith bit +''' + + + +def clear_bit(num, i): + mask = ~ (1 << i) # -0b10001 + return bin(num & mask) + + +def clear_all_bits_from_i_to_0(num, i): + mask = ~ ( (1 << (i+1)) - 1) + return bin(num & mask) + + +def clear_all_bits_from_most_sig_to_1(num, i): + mask = ( 1 << i) -1 + return bin(num & mask) + + +if __name__ == '__main__': + num = int('10010000', 2) + print clear_bit(num, 4) # '0b10000000' + + num = int('10010011', 2) + print clear_all_bits_from_i_to_0(num, 2) # '0b10010000' + + num = int('1110011', 2) + print clear_all_bits_from_most_sig_to_1(num, 2) #'0b11' diff --git a/src/neat_builtin_examples/sets/bit_operations/find_bit_len.py b/MY_BOOK/ebook_src/bitwise_operations/find_bit_len.py old mode 100644 new mode 100755 similarity index 63% rename from src/neat_builtin_examples/sets/bit_operations/find_bit_len.py rename to MY_BOOK/ebook_src/bitwise_operations/find_bit_len.py index d061435..81d90f0 --- a/src/neat_builtin_examples/sets/bit_operations/find_bit_len.py +++ b/MY_BOOK/ebook_src/bitwise_operations/find_bit_len.py @@ -1,28 +1,25 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" ''' Find how many bits a int has: 1) Start with a mask of 1 2) Mask with AND 3) if result (if true): count += 1 - (obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int)) - - >>> for i in range(17): print(find_bit_len(i)) + (obs: to find the int of a bin do int('1001', 2)) and to show in bin + do bin(int)) ''' - def find_bit_len(int_num): lenght = 0 while int_num: int_num >>= 1 lenght += 1 return lenght - - + if __name__ == '__main__': - import doctest - doctest.testmod() - + for i in range(17): + print(find_bit_len(i)) + print i.bit_length() diff --git a/src/neat_builtin_examples/sets/bit_operations/find_how_many_1_binary.py b/MY_BOOK/ebook_src/bitwise_operations/find_how_many_1_binary.py old mode 100644 new mode 100755 similarity index 69% rename from src/neat_builtin_examples/sets/bit_operations/find_how_many_1_binary.py rename to MY_BOOK/ebook_src/bitwise_operations/find_how_many_1_binary.py index 26a10f7..89fc44c --- a/src/neat_builtin_examples/sets/bit_operations/find_how_many_1_binary.py +++ b/MY_BOOK/ebook_src/bitwise_operations/find_how_many_1_binary.py @@ -1,21 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" ''' Find how many 1s in the binary: 1) Start with a mask of 1 2) Mask with AND 3) if result (if true): count += 1 - (obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int)) - - >>> find_how_many_1_in_a_binary(9) - 2 - + (obs: to find the int of a bin do int('1001', + 2)) and to show in bin do bin(int)) ''' - def find_how_many_1_in_a_binary(n): + ''' + >>> find_how_many_1_in_a_binary(9) + 2 + ''' + counter = 0 while n: if n & 1: @@ -24,9 +25,6 @@ def find_how_many_1_in_a_binary(n): return counter - - - if __name__ == '__main__': import doctest diff --git a/MY_BOOK/ebook_src/bitwise_operations/get_bit.py b/MY_BOOK/ebook_src/bitwise_operations/get_bit.py new file mode 100755 index 0000000..b212316 --- /dev/null +++ b/MY_BOOK/ebook_src/bitwise_operations/get_bit.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' Get a bit in a binary number: + 1) Shifts 1 over by i bits + 2) make an AND with the number + 3) all the other than the bit at i are clean, now compare to 0 + 4) if the new value is not 0, bit i is 1 +''' + + +def get_bit(num, i): + mask = 1 << i + return num & mask != 0 + + +if __name__ == '__main__': + num = int('0100100', 2) + get_bit(num, 0) # 0 + get_bit(num, 1) # 0 + get_bit(num, 2) # 1 + get_bit(num, 3) # 0 + get_bit(num, 4) # 0 + get_bit(num, 5) # 1 + get_bit(num, 6) # 0 + diff --git a/src/neat_builtin_examples/sets/bit_operations/get_float_rep_bin.py b/MY_BOOK/ebook_src/bitwise_operations/get_float_rep_bin.py old mode 100644 new mode 100755 similarity index 90% rename from src/neat_builtin_examples/sets/bit_operations/get_float_rep_bin.py rename to MY_BOOK/ebook_src/bitwise_operations/get_float_rep_bin.py index e8f7bd4..fb3814d --- a/src/neat_builtin_examples/sets/bit_operations/get_float_rep_bin.py +++ b/MY_BOOK/ebook_src/bitwise_operations/get_float_rep_bin.py @@ -1,20 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" ''' Given a real number between 0 and 1 (eg: 0.72), this method print the binary representation. If the Number cannot be represented accurately in binary, with at most 32 chars, print error: - +''' + +def get_float_rep(num): + ''' >>> get_float_rep(0.72) ('Error 2', '.1011100001010001111010111000010') >>> get_float_rep(0.1) ('Error 2', '.0001100110011001100110011001100') >>> get_float_rep(0.5) '.1' -''' + ''' -def get_float_rep(num): if num >= 1 or num <= 0: return 'Error 1' result = '.' while num: @@ -27,7 +29,7 @@ def get_float_rep(num): result += '0' num = r return result - + if __name__ == '__main__': import doctest diff --git a/src/neat_builtin_examples/sets/bit_operations/insert_small_bin_into_big_bin.py b/MY_BOOK/ebook_src/bitwise_operations/insert_small_bin_into_big_bin.py old mode 100644 new mode 100755 similarity index 88% rename from src/neat_builtin_examples/sets/bit_operations/insert_small_bin_into_big_bin.py rename to MY_BOOK/ebook_src/bitwise_operations/insert_small_bin_into_big_bin.py index 03257b8..292b169 --- a/src/neat_builtin_examples/sets/bit_operations/insert_small_bin_into_big_bin.py +++ b/MY_BOOK/ebook_src/bitwise_operations/insert_small_bin_into_big_bin.py @@ -1,33 +1,34 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' Given two 32-bit numbers, N and M, and two bit positions, i and j, this - method insert M into N such that M starts at bit j and ends at bit i: + method insert M into N such that M starts at bit j and ends at bit i: 1) clear the bits j thru i in N' 2) shift M so that it lines up with bits j thru i 3) merge M and N +''' +def insert_small_bin_into_big_bin(M, N, i, j): + ''' >>> N = 0b10000000000 >>> M = 0b10011 >>> j = 6 >>> i = 2 >>> insert_small_bin_into_big_bin(M, N, i, j) '0b10001001100' -''' + ''' -def insert_small_bin_into_big_bin(M, N, i, j): allOnes = ~0 left = allOnes << (j+1) # 1110000 right = ( (1 << i) - 1) # 0000111 mask = left | right # 1110111 N_cleared = N & mask M_shifted = M << i - + return bin( N_cleared | M_shifted) - - - + if __name__ == '__main__': import doctest diff --git a/src/neat_builtin_examples/sets/bit_operations/next_with_same_num_1s.py b/MY_BOOK/ebook_src/bitwise_operations/next_with_same_num_1s.py old mode 100644 new mode 100755 similarity index 67% rename from src/neat_builtin_examples/sets/bit_operations/next_with_same_num_1s.py rename to MY_BOOK/ebook_src/bitwise_operations/next_with_same_num_1s.py index 47ba953..6c2617e --- a/src/neat_builtin_examples/sets/bit_operations/next_with_same_num_1s.py +++ b/MY_BOOK/ebook_src/bitwise_operations/next_with_same_num_1s.py @@ -1,27 +1,19 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' Give a positive int, print the next smallest and next largest ints with same number of 1 bits. The brute force is: 1) find number of 1 bits 2) loop above and down until find same, checking for each - - >>> num = 0b1001 - >>> next = '0b1010' - >>> prev = '0b110' - >>> print_prev_same_1s(num) == prev - True - >>> print_next_same_1s(num) == next - True - ''' def print_prev_same_1s(num): - n1s = find_num_1s(num) + n1s = find_num_1s(num) # find prev i = num-1 while True: @@ -31,10 +23,10 @@ def print_prev_same_1s(num): i -= 1 if i < 0: return None - + def print_next_same_1s(num): - n1s = find_num_1s(num) - # find next + n1s = find_num_1s(num) + # find next i = num+1 while True: n1s_here = find_num_1s(i) @@ -43,8 +35,8 @@ def print_next_same_1s(num): i += 1 if i < 0: return None - - + + def find_num_1s(num): counter = 0 @@ -54,11 +46,14 @@ def find_num_1s(num): num >>= 1 return counter - - - + + + if __name__ == '__main__': - import doctest - doctest.testmod() + num = 0b1001 + n = '0b1010' + p = '0b110' + print_prev_same_1s(num) == p + print_next_same_1s(num) == n diff --git a/src/neat_builtin_examples/sets/bit_operations/num_bits_to_convert_2_nums.py b/MY_BOOK/ebook_src/bitwise_operations/num_bits_to_convert_2_nums.py old mode 100644 new mode 100755 similarity index 63% rename from src/neat_builtin_examples/sets/bit_operations/num_bits_to_convert_2_nums.py rename to MY_BOOK/ebook_src/bitwise_operations/num_bits_to_convert_2_nums.py index 90054de..3447d35 --- a/src/neat_builtin_examples/sets/bit_operations/num_bits_to_convert_2_nums.py +++ b/MY_BOOK/ebook_src/bitwise_operations/num_bits_to_convert_2_nums.py @@ -1,18 +1,12 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' This method returns the number of bits that are necessary to change to convert two numbers A and B: 1) XOR 2) count 1s - - >>> a = int('10010000', 2) - >>> b = int('01011010', 2) - >>> count_bits_swap(a, b) - 4 - >>> count_bits_swap2(a, b) - 4 ''' def count_bits_swap2(a, b): @@ -28,8 +22,8 @@ def count_bits_swap2(a, b): def count_bits_swap(a, b): m = a^b return count_1s(m) - - + + def count_1s(m): count = 0 while m: @@ -37,9 +31,10 @@ def count_1s(m): count +=1 m >>= 1 return count - + if __name__ == '__main__': - import doctest - doctest.testmod() - + a = int('10010000', 2) + b = int('01011010', 2) + print count_bits_swap(a, b) #4 + print count_bits_swap2(a, b) #4 diff --git a/MY_BOOK/ebook_src/bitwise_operations/set_bit.py b/MY_BOOK/ebook_src/bitwise_operations/set_bit.py new file mode 100755 index 0000000..eeb73fb --- /dev/null +++ b/MY_BOOK/ebook_src/bitwise_operations/set_bit.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +''' Set a bit in a binary number: + 1) Shifts 1 over by i bits + 2) make an OR with the number, only the value at bit i will change and all the others bit + of the mask are zero so will not affect the num +''' + + +def set_bit(num, i): + mask = 1 << i + return bin( num | mask ) + + +if __name__ == '__main__': + num = int('0100100', 2) + print set_bit(num, 0) #'0b100101' + print set_bit(num, 1) #'0b100110' + print set_bit(num, 2) # nothing change '0b100100' + print set_bit(num, 3) #'0b101100' + print set_bit(num, 4) #'0b110100' + print set_bit(num, 5) # nothing change '0b100100' diff --git a/MY_BOOK/ebook_src/bitwise_operations/swap_in_place.py b/MY_BOOK/ebook_src/bitwise_operations/swap_in_place.py new file mode 100755 index 0000000..5aee66a --- /dev/null +++ b/MY_BOOK/ebook_src/bitwise_operations/swap_in_place.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' + swapping values in place without extra memory +''' + + +def swap_bit(a, b): + ''' + >>> swap_bit(14, 73) + (73, 14) + ''' + a = a^b + b = a^b + a = a^b + return a, b + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/src/neat_builtin_examples/sets/bit_operations/swap_odd_even.py b/MY_BOOK/ebook_src/bitwise_operations/swap_odd_even.py old mode 100644 new mode 100755 similarity index 87% rename from src/neat_builtin_examples/sets/bit_operations/swap_odd_even.py rename to MY_BOOK/ebook_src/bitwise_operations/swap_odd_even.py index d640262..386627d --- a/src/neat_builtin_examples/sets/bit_operations/swap_odd_even.py +++ b/MY_BOOK/ebook_src/bitwise_operations/swap_odd_even.py @@ -1,6 +1,7 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' Swap odd and even bits in a smart way in a binary: 1) first for odds, take n and move the odd: @@ -8,17 +9,18 @@ (b) shift by right by 1 2) do the same to ints with 01010101 3) merge - - >>> num = 0b11011101 - >>> result = '0b1101110' - >>> swap_odd_even(num) == result - True - ''' def swap_odd_even(num): + ''' + >>> num = 0b11011101 + >>> result = '0b1101110' + >>> swap_odd_even(num) == result + True + ''' + mask_odd = 0xAA # 0b10101010 mask_even = 0x55 # 0b1010101 odd = num & mask_odd @@ -28,9 +30,6 @@ def swap_odd_even(num): return bin(odd | even) - - - if __name__ == '__main__': import doctest diff --git a/src/neat_builtin_examples/sets/bit_operations/update_bit.py b/MY_BOOK/ebook_src/bitwise_operations/update_bit.py old mode 100644 new mode 100755 similarity index 58% rename from src/neat_builtin_examples/sets/bit_operations/update_bit.py rename to MY_BOOK/ebook_src/bitwise_operations/update_bit.py index 61422c8..c31d713 --- a/src/neat_builtin_examples/sets/bit_operations/update_bit.py +++ b/MY_BOOK/ebook_src/bitwise_operations/update_bit.py @@ -1,26 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" ''' This method merges set bit and clean bit: 1) first clear the bit at i using a mask such as 1110111 2) then shift the intended value v by i bits 3) this will create a number with bit i to v and all other to 0 4) finally update the ith bit with or - - >>> num = int('10010000', 2) - >>> update_bit(num, 2, 1) - '0b10010100' ''' def update_bit(num, i, v): mask = ~ (1 << i) - return bin( (num & mask) | (v << i) ) - + return bin( (num & mask) | (v << i) ) + if __name__ == '__main__': - import doctest - doctest.testmod() + num = int('10010000', 2) + print update_bit(num, 2, 1) # '0b10010100' diff --git a/src/abstract_structures/stacks/__init__.py b/MY_BOOK/ebook_src/builtin_structures/__init__.py old mode 100644 new mode 100755 similarity index 100% rename from src/abstract_structures/stacks/__init__.py rename to MY_BOOK/ebook_src/builtin_structures/__init__.py diff --git a/MY_BOOK/ebook_src/builtin_structures/anagram.py b/MY_BOOK/ebook_src/builtin_structures/anagram.py new file mode 100755 index 0000000..bffc085 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/anagram.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from collections import Counter + +def is_anagram(s1, s2): + ''' + >>> is_anagram('cat', 'tac') + True + >>> is_anagram('cat', 'hat') + False + ''' + counter = Counter() + for c in s1: + counter[c] += 1 + + for c in s2: + counter[c] -= 1 + + for i in counter.values(): + if i: + return False + + return True + +''' verify if words are anagrams by comparing a sum of Unicode code +point of the character''' + +def get_unicode_sum(word): + s = 0 + for p in word: + s += ord(p) + return s + + +def is_anagram2(word1, word2): + ''' + >>> is_anagram2('cat', 'tac') + True + >>> is_anagram2('cat', 'hat') + False + ''' + return get_unicode_sum(word1) == get_unicode_sum(word2) + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/balance.txt b/MY_BOOK/ebook_src/builtin_structures/balance.txt new file mode 100755 index 0000000..27df907 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/balance.txt @@ -0,0 +1,9 @@ +__author__ = "bt3" + + +This is the classic "you have 8 balls/coins, which are the same weight, except for one which is slightly heavier than the others. You also have an old-style balance. What is the fewest number of weighings to find the heavy coin/ball? + +Answer: 2! You need to use every information available: +Weight 3 x 3 balls/coins. +If they weight the same: weight the 2 balls/coins left outside. +Else, measure 2 of the 3 heavier balls/coins. \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/balance_symbols.py b/MY_BOOK/ebook_src/builtin_structures/balance_symbols.py new file mode 100755 index 0000000..ff65f82 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/balance_symbols.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' +Given a N different open and close braces in a string "( { [ } ] )". +How do you check whether the string has matching braces. +''' + +from collections import Counter +def check_if_balance(string): + ''' + >>> check_if_balance('{[[(])}]') + True + >>> check_if_balance('{[[()}]') + False + >>> check_if_balance('') + True + ''' + table = Counter() + for i in string: + + index = str(ord(i))[0] + if i in '{[(': + table[index] += 1 + + elif i in ')}]': + table[index] -= 1 + + for i in table.values(): + if i !=-0: + return False + return True + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/check_if_2_numbers_sum_to_k.py b/MY_BOOK/ebook_src/builtin_structures/check_if_2_numbers_sum_to_k.py new file mode 100755 index 0000000..b9d7cbf --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/check_if_2_numbers_sum_to_k.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +""" +Given an integer x and an unsorted array of integers, describe an +algorithm to determine whether two of the numbers add up to x. + +1. Using hash tables. +2. Sorting the array and keeping two pointers in the array, one in +the beginning and one in the end. Whenever the sum of the current +two integers is less than x, move the first pointer forwards, and +whenever the sum is greater than x, move the second pointer +backwards. O(nln n). +3. Create a BST with x minus each element in the array. +Check whether any element of the array appears in the BST. +It takes O(nlog n) times two. +""" + +from collections import defaultdict, Counter + +def check_sum(array, k): + ''' + >>> check_sum([3, 2, 6, 7, 9, 1], 8) + [(6, 2), (1, 7)] + >>> check_sum([5, 2, 6, 7, 9, 1], 4) + [] + >>> + ''' + + dict = defaultdict() + res = [] + + for i in array: + if k-i in dict: + res.append((i, k-i)) + del dict[k-i] + else: + dict[i] = 1 + + return res + + +def check_sum2(array, k): + ''' + >>> check_sum2([1, 4, 2, 7, 1, 3, 10, 15, 3, 1], 6) + set([(3, 3)]) + >>> check_sum2([1, 4, 2, 7, 1, 3, 10, 15, 3, 1], 0) + set([]) + ''' + + dict = Counter() + res = set() + + for i in array: + dict[i] += 1 + + for i in array: + if dict[k-i] > 0: + if i == k-i and dict[k-i] > 1: + res.add((i, k-i)) + dict[k-i] -= 2 + elif i == k-i: + res.add((i, k-i)) + dict[k-i] -= 1 + + return res + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/check_if_3_numbers_sum_to_zero.py b/MY_BOOK/ebook_src/builtin_structures/check_if_3_numbers_sum_to_zero.py new file mode 100755 index 0000000..33c3e3e --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/check_if_3_numbers_sum_to_zero.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' Determine if an Array of integers contains 3 numbers that sum to 0 ''' + +from collections import defaultdict + +def find_3_number(array): + ''' + >>> find_3_number([1,5,56,11,-3,-12]) + 1 11 -12 + True + >>> find_3_number([] ) + False + ''' + hash_ = defaultdict() + for i in array: + hash_[i] = 1 + + for i, x in enumerate(array): + for y in array[i+1:]: + if -(x+y) in hash_: + print x, y, -(x+y) + return True + + return False + + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/check_non_overlapping_intervals.py b/MY_BOOK/ebook_src/builtin_structures/check_non_overlapping_intervals.py new file mode 100755 index 0000000..f8213ef --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/check_non_overlapping_intervals.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' +given an array of intervals, return max number of non-overlapping intervals +''' + +from collections import defaultdict + +def non_overlapping(array): + ''' + >>> non_overlapping([(1,2), (2,5), (1, 6)]) + [[(1, 2), (2, 5)]] + >>> non_overlapping([(1,4), (2,5), (3, 6)]) + [] + ''' + total = [] + + for i, t in enumerate(array): + start = t[0] + end = t[1] + for tt in array[i+1:] : + if end <= tt[0]: + total.append([(start, end), (tt[0], tt[1])]) + + return total + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/convert_numerical_bases.py b/MY_BOOK/ebook_src/builtin_structures/convert_numerical_bases.py new file mode 100755 index 0000000..999d40e --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/convert_numerical_bases.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' convert an integer to a string in any base''' + +def convert_from_dec_to_any_base(number, base): + ''' + >>> number, base = 9, 2 + >>> convert_from_dec_to_any_base(number, base) + '1001' + ''' + + convertString = '012345679ABCDEF' + + if number < base: + return convertString[number] + + else: + return convert_from_dec_to_any_base(number//base, base) + \ + convertString[number%base] + + + +def convert_from_decimal_to_binary(number, base): + ''' + >>> number, base = 9, 2 + >>> convert_from_decimal_to_binary(number, base) + 1001 + ''' + + multiplier, result = 1, 0 + + while number > 0: + result += number%base*multiplier + multiplier *= 10 + number = number//base + + return result + + + +def convert_from_decimal_larger_bases(number, base): + ''' + >>> number, base = 31, 16 + >>> convert_from_decimal_larger_bases(number, base) + '1F' + ''' + strings = "0123456789ABCDEFGHIJ" + result = "" + + while number > 0: + digit = number%base + result = strings[digit] + result + number = number//base + + return result + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/src/neat_builtin_examples/lists_and_strings/conv_str2int.py b/MY_BOOK/ebook_src/builtin_structures/convert_str_2_int.py old mode 100644 new mode 100755 similarity index 61% rename from src/neat_builtin_examples/lists_and_strings/conv_str2int.py rename to MY_BOOK/ebook_src/builtin_structures/convert_str_2_int.py index ec7f8c3..bdf875d --- a/src/neat_builtin_examples/lists_and_strings/conv_str2int.py +++ b/MY_BOOK/ebook_src/builtin_structures/convert_str_2_int.py @@ -1,9 +1,10 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python -''' two routines to convert str to int and int to str: - - bc: negative str, zero, exp numbers (ex. 1e5), other bases, NAN +__author__ = "bt3" + + +def conv_int2str(int1): + ''' >>> conv_str2int('367') 367 >>> conv_str2int('0') @@ -12,46 +13,59 @@ -10 >>> conv_str2int('1e5') 100000 - >>> conv_int2str(0) - '0' - >>> conv_int2str(1e5) - '100000' - >>> conv_int2str(367) - '367' - >>> conv_int2str(-10) - '-10' -''' + ''' -def conv_int2str(int1): aux_dict = {key:value for key in range(10) for value in '0123456789'[key]} - if int1 == 0: return '0' # REMEMBER TO HANDLE 0 - if int1 < 0: # REMEMBER TO HANDLE NEGATIVE + + if int1 == 0: + return '0' + elif int1 < 0: sign = '-' int1 = int1*(-1) else: sign = '' + + aux_ls = [] + while int1 > 0: c = int1%10 int1 = int1//10 cadd = aux_dict[c] aux_ls.append(cadd) - aux_ls.reverse() # REMEMBER TO REVERSE + + aux_ls.reverse() + return sign + ''.join(aux_ls) - + def conv_str2int(str1): - if not str1: return None + ''' + >>> conv_int2str(0) + '0' + >>> conv_int2str(1e5) + '100000' + >>> conv_int2str(367) + '367' + >>> conv_int2str(-10) + '-10' + ''' + if not str1: + return None + aux_dict = {key:value for value in range(10) for key in '0123456789'[value]} - if str1[0] == '-': + + if str1[0] == '-': sign = -1 - str1 = str1[1:] # REMEMBER TO CUT THE SIGN FROM THE STR - else: + str1 = str1[1:] + else: sign = 1 + dec, result = 1, 0 - for i in range(len(str1)-1, -1, -1): # REMEMBER TO FINISH IN -1, NOT 0, AND - aux = str1[i] # AND DO THE STEPS -1 + + for i in range(len(str1)-1, -1, -1): + aux = str1[i] if aux == 'e': exp_num = conv_str2int(str1[i+1:]) number = conv_str2int(str1[:i]) @@ -59,8 +73,9 @@ def conv_str2int(str1): break result += aux_dict[aux]*dec dec *= 10 + return result*sign - + if __name__ == '__main__': import doctest diff --git a/src/neat_builtin_examples/dicts/count_unique_words_.py b/MY_BOOK/ebook_src/builtin_structures/count_unique_words_On2.py old mode 100644 new mode 100755 similarity index 81% rename from src/neat_builtin_examples/dicts/count_unique_words_.py rename to MY_BOOK/ebook_src/builtin_structures/count_unique_words_On2.py index fdf66c3..7b54490 --- a/src/neat_builtin_examples/dicts/count_unique_words_.py +++ b/MY_BOOK/ebook_src/builtin_structures/count_unique_words_On2.py @@ -1,21 +1,26 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" import collections import string import sys + def count_unique_word(): + words = collections.defaultdict(int) - strip = string.whitespace + string.punctuation + string.digits + "\"'" + + strip = string.whitespace + string.punctuation + string.digits + "\"'" + for filename in sys.argv[1:]: with open(filename) as file: - for line in file: + for line in file: for word in line.lower().split(): word = word.strip(strip) if len(word) > 2: words[word] = +1 + for word in sorted(words): print("'{0}' occurs {1} times.".format(word, words[word])) - + diff --git a/MY_BOOK/ebook_src/builtin_structures/delete_duplicate_char_str.py b/MY_BOOK/ebook_src/builtin_structures/delete_duplicate_char_str.py new file mode 100755 index 0000000..9f8b9fc --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/delete_duplicate_char_str.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' find and delete all the duplicate characters in a string ''' + +from collections import Counter + +def delete_unique(str1): + ''' + >>> delete_unique("Trust no one") + 'on' + >>> delete_unique("Mulder?") + '' + ''' + + str_strip = ''.join(str1.split()) + repeat = Counter() + + for c in str_strip: + repeat[c] += 1 + + result = '' + for c, count in repeat.items(): + if count > 1: + result += c + + return result + + +def removing_duplicates_seq(str1): + ''' + >>> delete_unique("Trust no one") + 'on' + >>> delete_unique("Mulder?") + '' + ''' + seq = str1.split() + result = set() + for item in seq: + if item not in result: + #yield item + result.add(item) + return result + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/MY_BOOK/ebook_src/builtin_structures/fibonacci.py b/MY_BOOK/ebook_src/builtin_structures/fibonacci.py new file mode 100755 index 0000000..584b611 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/fibonacci.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def fib_generator(): + a, b = 0, 1 + + while True: + yield b + a, b = b, a+b + + +def fib(n): + ''' + >>> fib(2) + 1 + >>> fib(5) + 5 + >>> fib(7) + 13 + ''' + if n < 3: + return 1 + + a, b = 0, 1 + count = 1 + + while count < n: + count += 1 + a, b = b, a+b + + return b + + +def fib_rec(n): + ''' + >>> fib_rec(2) + 1 + >>> fib_rec(5) + 5 + >>> fib_rec(7) + 13 + ''' + if n < 3: + return 1 + return fib_rec(n - 1) + fib_rec(n - 2) + + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + + fib = fib_generator() + print(next(fib)) + print(next(fib)) + print(next(fib)) + print(next(fib)) diff --git a/src/neat_builtin_examples/lists_and_strings/find_0_MxN_replace_cols_rows.py b/MY_BOOK/ebook_src/builtin_structures/find_0_MxN_replace_cols_rows.py old mode 100644 new mode 100755 similarity index 89% rename from src/neat_builtin_examples/lists_and_strings/find_0_MxN_replace_cols_rows.py rename to MY_BOOK/ebook_src/builtin_structures/find_0_MxN_replace_cols_rows.py index f306d83..9ab67c3 --- a/src/neat_builtin_examples/lists_and_strings/find_0_MxN_replace_cols_rows.py +++ b/MY_BOOK/ebook_src/builtin_structures/find_0_MxN_replace_cols_rows.py @@ -1,8 +1,8 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + - def find_0_MxN(m): ''' find 0s in a matrix and replace the col and row to 0s: >>> m1 = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]] @@ -13,6 +13,7 @@ def find_0_MxN(m): [[0, 2, 3, 4], [0, 0, 0, 0], [0, 10, 11, 12], [0, 14, 15, 16]] ''' index = [] + for row in range(len(m)): for col in range(len(m[0])): if m[row][col] == 0: @@ -24,9 +25,10 @@ def find_0_MxN(m): m[row][i] = 0 for i in range(len(m[0])): m[i][col] = 0 + return m - + if __name__ == '__main__': import doctest doctest.testmod() diff --git a/MY_BOOK/ebook_src/builtin_structures/find_dice_probabilities.py b/MY_BOOK/ebook_src/builtin_structures/find_dice_probabilities.py new file mode 100755 index 0000000..265c9b1 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_dice_probabilities.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' +given 2 dice, determine number of ways to sum S if all dice are rolled +''' + +from collections import Counter, defaultdict + +def find_dice_probabilities(S=5, n_faces=6): + if S > 2*n_faces or S < 2: + return None + + cdict = Counter() + ddict = defaultdict(list) + + for dice1 in range(1, n_faces+1): + for dice2 in range(1, n_faces+1): + t = [dice1, dice2] + cdict[dice1+dice2] += 1 + ddict[dice1+dice2].append( t) + + return [cdict[S], ddict[S]] + + + + + +if __name__ == '__main__': + results = find_dice_probabilities() + assert(results[0] == len(results[1])) diff --git a/MY_BOOK/ebook_src/builtin_structures/find_edit_distance.py b/MY_BOOK/ebook_src/builtin_structures/find_edit_distance.py new file mode 100755 index 0000000..6fc6e81 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_edit_distance.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' computes the edit distance between two strings ''' + + +def find_edit_distance(str1, str2): + ''' + >>> s = 'sunday' + >>> t = 'saturday' + >>> find_edit_distance(s, t) + 3 + ''' + + m = len(str1) + n = len(str2) + diff = lambda c1, c2: 0 if c1 == c2 else 1 + + E = [[0] * (n + 1) for i in range(m + 1)] + + for i in range(m + 1): + E[i][0] = i + + for j in range(1, n + 1): + E[0][j] = j + + for i in range(1, m + 1): + for j in range(1, n + 1): + E[i][j] = min(E[i-1][j] + 1, E[i][j-1] + 1, E[i-1][j-1] + diff(str1[i-1], str2[j-1])) + + return E[m][n] + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + + + + diff --git a/MY_BOOK/ebook_src/builtin_structures/find_first_non_repetead_char.py b/MY_BOOK/ebook_src/builtin_structures/find_first_non_repetead_char.py new file mode 100755 index 0000000..5489f7d --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_first_non_repetead_char.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +from collections import Counter + +def find_non_rep_char(s1): + ''' + >>> s1 = 'aabbcceff' + >>> find_non_rep_char(s1) + e + >>> find_non_rep_char('ccc') + ''' + + aux_dict = Counter() + + for i in s1: + aux_dict[i] += 1 + + for k, v in aux_dict.items(): + if v < 2: + print k + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/src/neat_builtin_examples/numbers/finding_gcd.py b/MY_BOOK/ebook_src/builtin_structures/find_gcd.py old mode 100644 new mode 100755 similarity index 73% rename from src/neat_builtin_examples/numbers/finding_gcd.py rename to MY_BOOK/ebook_src/builtin_structures/find_gcd.py index dd7cb82..d9dfa4c --- a/src/neat_builtin_examples/numbers/finding_gcd.py +++ b/MY_BOOK/ebook_src/builtin_structures/find_gcd.py @@ -1,13 +1,14 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + def finding_gcd(a, b): ''' implements the greatest common divider algorithm ''' while(b != 0): result = b - a, b = b, a % b + a, b = b, a % b return result @@ -22,7 +23,7 @@ if __name__ == '__main__': - - - - + + + + diff --git a/MY_BOOK/ebook_src/builtin_structures/find_if_substr.py b/MY_BOOK/ebook_src/builtin_structures/find_if_substr.py new file mode 100755 index 0000000..8166bda --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_if_substr.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def find_substr(s1, s2): + + if len(s1) < len(s2): + bs = s2 + ss = s1 + else: + bs = s1 + ss = s2 + + ps = 0 + + for c in bs: + + if ss[ps] == c: + ps += 1 + else: + ps = 0 + + if ps == len(ss)-1: + return True + + return False + + + +if __name__ == '__main__': + s1 = 'buffy is a vampire slayer' + s2 = 'vampire' + s3 = 'angel' + assert(find_substr(s2, s1) == True) + assert(find_substr(s3, s1) == False) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/find_if_unique_char.py b/MY_BOOK/ebook_src/builtin_structures/find_if_unique_char.py new file mode 100755 index 0000000..3e88c46 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_if_unique_char.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +import collections + +def find_if_unique_chars(word): + """ + >>> find_if_unique_chars('abcde') + True + >>> find_if_unique_chars('abcae') + False + """ + + unique = True + + counter = collections.Counter() + + for c in word: + if not counter[c]: + counter[c] += 1 + else: + unique = False + + return unique + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/find_largest_sum.py b/MY_BOOK/ebook_src/builtin_structures/find_largest_sum.py new file mode 100755 index 0000000..9b79ac8 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_largest_sum.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +''' + You are given an array of integers (both positive and negative). + Find the contiguous sequence with the largest sum. +''' + + +def find_largest_sum(array): + ''' + >>> find_largest_sum([-1, 2, -3, 5, 3, 1, -16, 7, 1, -13, 1]) + 9 + >>> find_largest_sum([]) + 0 + >>> find_largest_sum([1]) + 1 + ''' + + sum_ = 0 + sum_here = 0 + + for i in array: + + sum_here += i + + if sum_here < 0: + sum_here = 0 + + if sum_ < sum_here: + sum_ = sum_here + + return sum_ + + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/find_longest_inc_subseq.py b/MY_BOOK/ebook_src/builtin_structures/find_longest_inc_subseq.py new file mode 100755 index 0000000..38e3b9b --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_longest_inc_subseq.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' find the longest continuous increasing subsequence''' + + +def find_long_con_inc(seq): + ''' + >>> find_long_con_inc([1, -2, 3, 5, 1, -1, 4, -1, 6]) + [-2, 3, 5] + >>> find_long_con_inc([1, 3, -2, 3, 5, 6]) + [-2, 3, 5, 6] + >>> find_long_con_inc([1, 3, 4, -13, 2, 5, 8, -1, 2,-17]) + [-13, 2, 5, 8] + ''' + + res, aux = [], [] + seq.append(-float('infinity')) + + for i, n in enumerate(seq[:-1]): + aux.append(n) + if n > seq[i+1]: + if len(res) < len(aux): + res = aux[:] + aux = [] + + return res + + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/MY_BOOK/ebook_src/builtin_structures/find_longest_str_unique_chars.py b/MY_BOOK/ebook_src/builtin_structures/find_longest_str_unique_chars.py new file mode 100755 index 0000000..a73144e --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_longest_str_unique_chars.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' +given a string, find longest string with unique characters +''' + +def find_longest(string): + ''' + >>> find_longest('abfgrhgtrdsandwejfhdasjcbdsjvrejwghireeej') + 'wejfhdas' + >>> find_longest('abcabcabcabcdefabcccc') + 'defabc' + ''' + maxs = '' + result = '' + + for c in string: + if c in result: + if len(maxs) < len(result): + maxs = result + result = '' + else: + result += c + + if result and len(maxs) < len(result): + maxs = result + + return maxs + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/find_non_repeating_number.py b/MY_BOOK/ebook_src/builtin_structures/find_non_repeating_number.py new file mode 100755 index 0000000..8d1dc14 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_non_repeating_number.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from collections import defaultdict + + +def find_unique_number(array): + ''' + >>> find_unique_number([1, 3, 6, 1, 5, 6, 9, 3, 7]) + [1, 6, 3] + >>> find_unique_number([1, 3, 5, 6, 9, 7]) + [] + ''' + + table = defaultdict() + total = [] + + for i in array: + if i in table: + total.append(i) + else: + table[i] = 1 + + return total + + + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/find_product_without_division.py b/MY_BOOK/ebook_src/builtin_structures/find_product_without_division.py new file mode 100755 index 0000000..611842e --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_product_without_division.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +'''Given an array of numbers, replace each number with the product of all +the numbers in the array except the number itself *without* using division +''' + + +def find_product_without_division(seq): + ''' + >>> seq = [2,3,4] + >>> find_product_without_division(seq) + [12, 8, 6] + ''' + + forw = [] + bacw = [] + + for i in range(len(seq)): + + prod_f, prod_b = 1, 1 + + for next in range(i+1, len(seq)): + prod_f *= seq[next] + + for before in range(0, i): + prod_b *= seq[before] + + forw.append(prod_f) + bacw.append(prod_b) + + for i in range(len(seq)): + seq[i] = forw[i] * bacw[i] + + return seq + + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/src/neat_builtin_examples/dicts/find_top_N_recurring_words.py b/MY_BOOK/ebook_src/builtin_structures/find_top_N_recurring_words.py old mode 100644 new mode 100755 similarity index 60% rename from src/neat_builtin_examples/dicts/find_top_N_recurring_words.py rename to MY_BOOK/ebook_src/builtin_structures/find_top_N_recurring_words.py index d699fe7..91dfc8f --- a/src/neat_builtin_examples/dicts/find_top_N_recurring_words.py +++ b/MY_BOOK/ebook_src/builtin_structures/find_top_N_recurring_words.py @@ -1,6 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" from collections import Counter @@ -8,24 +8,20 @@ def find_top_N_recurring_words(seq, N): ''' find the top N recurring words in a file: 1) use a hash table to find counts 2) sort the list on base of the maximum counts - 3) return the last N words ''' + 3) return the last N words + ''' dcounter = Counter() for word in seq.split(): - dcounter[word] += 1 + dcounter[word] += 1 + return dcounter.most_common(N) - -def test_find_top_N_recurring_words(module_name='this module'): - seq = 'buffy angel monster xander a willow gg buffy the monster super buffy angel' - N = 3 - assert(find_top_N_recurring_words(seq, N) == [('buffy', 3), ('monster', 2), ('angel', 2)]) - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - if __name__ == '__main__': - test_find_top_N_recurring_words() + seq = 'buffy angel monster xander a willow gg buffy the monster super buffy angel' + N = 3 + assert(find_top_N_recurring_words(seq, N) == [('buffy', 3), ('monster', 2), ('angel', 2)]) + diff --git a/MY_BOOK/ebook_src/builtin_structures/find_two_missing_numbers_in_sequence.py b/MY_BOOK/ebook_src/builtin_structures/find_two_missing_numbers_in_sequence.py new file mode 100755 index 0000000..e532a18 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/find_two_missing_numbers_in_sequence.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +""" +Two numbers out of n numbers from 1 to n are missing. +The remaining n-2 numbers are in the array but not sorted. +Find the missing numbers The sum1 is the sum of all the elements in n. +The sum2 is the sum of all the elements in n-2. sum1 - sum2 = num1 + num2 = s. +The prod1 is the prod of all the elements in n. The prod2 is the prod of all +the elements in n-2. prod1/prod2 = num1*num2 =p. +Runtime is O(n), because it scan 3 times. Space is O(1) + +In case of finding one integer, Let the missing number be M. We know that +the sum of first N natural numbers is N*(N+1)/2. Traverse through the array +once and calculate the sum. This is the sum of first N natural numbers - +M or S=N*(N+1)/2 - M. Therefore M = N*(N+1)/2 - S. +""" + +import math + +def find_two_missing_numbers(l1): + ''' + >>> l1 = [1, 3, 5] + >>> find_two_missing_numbers(l1) + (4, 2) + ''' + + n_min_2 = len(l1) + n = n_min_2 + 2 + sum1, sum2, prod1, prod2 = 0, 0, 1, 1 + sum2 = sum(l1[:]) + sum1 = sum(range(1,n+1)) + s = sum1 - sum2 + + for i in range(1, n-1): + prod1 = prod1*i + prod2 = prod2*l1[i-1] + + prod1 = prod1*n*(n-1) + p = prod1/prod2 + num1 = (s + math.sqrt(s*s - 4*p))/2 + num2 = (s - math.sqrt(s*s - 4*p))/2 + + return int(num1), int(num2) + + +if __name__ == '__main__': + import doctest + doctest.testmod() + + + + + + diff --git a/MY_BOOK/ebook_src/builtin_structures/get_float_rep_bin.py b/MY_BOOK/ebook_src/builtin_structures/get_float_rep_bin.py new file mode 100755 index 0000000..156cb77 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/get_float_rep_bin.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' Given a real number between 0 and 1 (eg: 0.72), this method print the + binary representation. If the Number cannot be represented accurately + in binary, with at exit most 32 chars, print error: +''' + +def get_float_rep(num): + if num >= 1 or num <= 0: return 'Error 1' + result = '.' + while num: + if len(result) >= 32: return 'Error 2', result + r = num*2 + if r >= 1: + result += '1' + num = r - 1 + else: + result += '0' + num = r + return result + + +if __name__ == '__main__': + print get_float_rep(0.72) #('Error 2', '.1011100001010001111010111000010') + print get_float_rep(0.1) # ('Error 2', '.0001100110011001100110011001100') + print get_float_rep(0.5) #'.1' diff --git a/MY_BOOK/ebook_src/builtin_structures/interserction_two_arrays.py b/MY_BOOK/ebook_src/builtin_structures/interserction_two_arrays.py new file mode 100755 index 0000000..b0868ef --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/interserction_two_arrays.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def intersection_two_arrays_sets(seq1, seq2): + ''' + >>> intersection_two_arrays_sets([1,2,3,5,7,8], [3,5,6]) + set([3, 5]) + >>> intersection_two_arrays_sets([1,2,7,8], [3,5,6]) + set([]) + ''' + # O(n) + set1 = set(seq1) + set2 = set(seq2) + + return set1.intersection(set2) #same as list(set1 & set2) + + +def intersection_two_arrays_On2(seq1, seq2): + ''' + >>> intersection_two_arrays_On2([1,2,3,5,7,8], [3,5,6]) + [3, 5] + >>> intersection_two_arrays_On2([1,2,7,8], [3,5,6]) + [] + ''' + + final = [] + + for i in seq1: + for j in seq2: + if i == j: + final.append(i) + + return final + + +def intersection_two_arrays_On(seq1, seq2): + ''' + >>> intersection_two_arrays_On([1,2,3,5,7,8], [3,5,6]) + [5, 3] + >>> intersection_two_arrays_On([1,2,7,8], [3,5,6]) + [] + ''' + + final = [] + + while seq1 and seq2: + + if seq1[-1] == seq2[-1]: + final.append(seq1.pop()) + seq2.pop() + elif seq1[-1] > seq2[-1]: + seq1.pop() + else: + seq2.pop() + + return final + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/MY_BOOK/ebook_src/builtin_structures/max_subarray_stocks.py b/MY_BOOK/ebook_src/builtin_structures/max_subarray_stocks.py new file mode 100755 index 0000000..11bf739 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/max_subarray_stocks.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +def beating_stock(array): + + imin = 0 + + # first deal is just buying in the next day (1) + deal = [array[1] - array[imin], imin, 1] + + for i, d in enumerate(array): + + deal_here = d - array[imin] + + if deal_here > deal[0]: + deal = [deal_here, imin, i] + + elif d < array[imin]: + imin = i + + return deal[0], array[deal[1]], array[deal[2]] + + +def beating_stock2(array): + + deal = 0 + min_value = array[0] + + for i, d in enumerate(array): + + deal_here = d - min_value + + if deal_here > deal: + deal = deal_here + + else: + if min_value > array[i]: + min_value = array[i] + + return deal + + + +if __name__ == '__main__': + array = [7, 2, 3, 6, 5, 8, 5, 3, 4] + + deal = beating_stock(array) + print("Profit: %d, buying at %d, selling at %d." %(deal[0], deal[1], deal[2])) + + deal = beating_stock2(array) + print "Profit: " + str(deal) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/number_of_zeros_factorial.txt b/MY_BOOK/ebook_src/builtin_structures/number_of_zeros_factorial.txt new file mode 100755 index 0000000..066451c --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/number_of_zeros_factorial.txt @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +How to know how many 0 are in 100! + +You look for the primes that multiply to 10, i.e. 2 and 5. + +There are more 5 than 2s so you can count the fives. + +there is 100/5 = 20, so 20 5s. However, there are two 5s in 25, 50, 75 and 100. + +result: 20+4 = 24 \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/palindrome.py b/MY_BOOK/ebook_src/builtin_structures/palindrome.py new file mode 100755 index 0000000..0002cee --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/palindrome.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +from collections import defaultdict + +def is_palindrome(array): + ''' + >>> is_palindrome('subi no onibus') + True + >>> is_palindrome('helllo there') + False + >>> is_palindrome('h') + True + >>> is_palindrome('') + True + ''' + array = array.strip(' ') + if len(array) < 2: + return True + + if array[0] == array[-1]: + return is_palindrome(array[1:-1]) + else: + return False + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/permutations.py b/MY_BOOK/ebook_src/builtin_structures/permutations.py new file mode 100755 index 0000000..14c4134 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/permutations.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +def perm(str1): + ''' + >>> perm('123') + ['123', '132', '231', '213', '312', '321'] + ''' + + if len(str1) < 2: + return str1 + + res = [] + for i, c in enumerate(str1): + for cc in perm(str1[i+1:] + str1[:i]): + res.append(c + cc) + return res + + +def perm2(str1): + ''' + >>> perm2('123') + ['123', '132', '213', '231', '312', '321'] + ''' + from itertools import permutations + return [''.join(p) for p in permutations(str1)] + + +def ispermutation(s1, s2): + ''' + >>> ispermutation('231', '123') + True + >>> ispermutation('231', '153') + False + ''' + + from collections import Counter + aux = Counter() + for i in s1: + aux[i] += 1 + for i in s2: + aux[i] -= 1 + for v in aux.values(): + if v != 0: + return False + return True + + + + +def ispermutation2(s1, s2): + ''' + >>> ispermutation2('231', '123') + True + >>> ispermutation2('231', '153') + False + ''' + if sorted(s1) == sorted(s2): + return True + else: + return False + + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/MY_BOOK/ebook_src/builtin_structures/permutations_alphanumeric.py b/MY_BOOK/ebook_src/builtin_structures/permutations_alphanumeric.py new file mode 100755 index 0000000..1c0ff96 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/permutations_alphanumeric.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' Write code to generate all possible case permutations of a given +lower-cased string +''' + +def alpha_permutation(string): + ''' + >>> alpha_permutation('0ab') + ['0Ab', '0Ab', '0ab', '0ab', '0Ba', '0Ba', '0ba', '0ba', 'ab0', 'a0b', 'a0b', 'b0a', 'b0a', 'ba0'] + >>> alpha_permutation('') + '' + ''' + + if len(string) < 2: + return string + + result = [] + + for i, c in enumerate(string): + rest = string[i+1:] + string[:i] + for cc in alpha_permutation(rest): + if cc.isalpha(): + result.append(c.upper() + cc) + result.append(c + cc) + + return result + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/primes.py b/MY_BOOK/ebook_src/builtin_structures/primes.py new file mode 100755 index 0000000..59dc1ed --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/primes.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' +find prime factors of a number. +''' + +import math +import random + +def find_prime_factors(n): + ''' + >>> find_prime_factors(14) + [2, 7] + >>> find_prime_factors(19) + [] + ''' + + divisors = [d for d in range(2, n//2 + 1) if n % d == 0] + primes = [d for d in divisors if is_prime(d)] + + return primes + + +def is_prime(n): + for j in range(2, int(math.sqrt(n))): + if (n % j) == 0: + return False + return True + + +''' return a n-bit prime ''' +def generate_prime(number=3): + while 1: + p = random.randint(pow(2, number-2), pow(2, number-1)-1) + p = 2 * p + 1 + if find_prime_factors(p): + return p + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/builtin_structures/prod_other_ints.py b/MY_BOOK/ebook_src/builtin_structures/prod_other_ints.py new file mode 100755 index 0000000..3caa9bf --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/prod_other_ints.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def get_products_of_all_except_at_index(array): + ''' + >>> a = [1, 7, 3, 4] + >>> get_products_of_all_except_at_index(a) + [84, 12, 28, 21] + ''' + total = 1 + for n in array: + total *= n + + new_array = [] + for n in array: + if n is not 0: + item = total/n + new_array.append(item) + else: + new_array.append(n) + + return new_array + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/ransom_note.py b/MY_BOOK/ebook_src/builtin_structures/ransom_note.py new file mode 100755 index 0000000..75a07f8 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/ransom_note.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +from collections import Counter + +def check_if_ransom_note(magazines, note): + count = Counter() + pm, pn = 0, 0 + + while pn < len(note) and pm < len(magazines): + char_note = note[pn] + if count[char_note]>0: + count[char_note] -= 1 + pn += 1 + else: + char_magazine = magazines[pm] + count[char_magazine] += 1 + pm +=1 + + return pn == len(note) + + + +if __name__ == '__main__': + + magazines1 = "avfegthhgrebvkdsvnijnvyijfdmckdsmovkmmfvskumvl;cdkmioswckofjbkreenyukjemjgnmkmvkmnvdkmvkr g gmvdvmldm vldfkmbldkmlvdkm" + magazines2 = "adfsfa" + note = "you should disobey" + + print(check_if_ransom_note(magazines1, note)) + print(check_if_ransom_note(magazines2, note)) diff --git a/MY_BOOK/ebook_src/builtin_structures/reverse_string.py b/MY_BOOK/ebook_src/builtin_structures/reverse_string.py new file mode 100755 index 0000000..e20d32f --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/reverse_string.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def revert(string): + ''' + >>> s = 'hello' + >>> revert(s) + 'olleh' + >>> revert('') + '' + ''' + return string[::-1] + + + +def reverse_string_inplace(s): + ''' + >>> s = 'hello' + >>> reverse_string_inplace(s) + 'olleh' + >>> reverse_string_inplace('') + '' + ''' + if s: + s = s[-1] + reverse_string_inplace(s[:-1]) + return s + + + + + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/builtin_structures/reverse_words.py b/MY_BOOK/ebook_src/builtin_structures/reverse_words.py new file mode 100755 index 0000000..775ad99 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/reverse_words.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +def reversing_words(word): + """ + >>> reversing_words('buffy is awesome') + 'awesome is buffy' + """ + new_word = [] + + words = word.split(' ') + for word in words[::-1]: + new_word.append(word) + + return " ".join(new_word) + + +def reversing_words2(s): + """ + >>> reversing_words2('buffy is awesome') + 'awesome is buffy' + """ + words = s.split() + return ' '.join(reversed(words)) + + +def reversing_words3(s): + """ + >>> reversing_words('buffy is awesome') + 'awesome is buffy' + """ + words = s.split(' ') + words.reverse() + return ' '.join(words) + + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/src/neat_builtin_examples/lists_and_strings/rotate_NxN.py b/MY_BOOK/ebook_src/builtin_structures/rotate_NxN.py old mode 100644 new mode 100755 similarity index 85% rename from src/neat_builtin_examples/lists_and_strings/rotate_NxN.py rename to MY_BOOK/ebook_src/builtin_structures/rotate_NxN.py index d238a94..f841bad --- a/src/neat_builtin_examples/lists_and_strings/rotate_NxN.py +++ b/MY_BOOK/ebook_src/builtin_structures/rotate_NxN.py @@ -1,8 +1,7 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" - def rotate_NxN(m): n = len(m) for layer in range(n//2): @@ -16,7 +15,7 @@ def rotate_NxN(m): m[last][last-offset] = m[i][last] m[i][last] = top return m - + def main(): @@ -25,7 +24,7 @@ def main(): assert(rotate_NxN(m) == mr) m2 = [[1,2,3],[4,5,6],[7,8,9]] print(rotate_NxN(m2)) - + if __name__ == '__main__': main() diff --git a/src/neat_builtin_examples/dicts/runtime_dicts_with_timeit_module.py b/MY_BOOK/ebook_src/builtin_structures/runtime_dicts_with_timeit_module.py old mode 100644 new mode 100755 similarity index 58% rename from src/neat_builtin_examples/dicts/runtime_dicts_with_timeit_module.py rename to MY_BOOK/ebook_src/builtin_structures/runtime_dicts_with_timeit_module.py index c8138fc..b54c637 --- a/src/neat_builtin_examples/dicts/runtime_dicts_with_timeit_module.py +++ b/MY_BOOK/ebook_src/builtin_structures/runtime_dicts_with_timeit_module.py @@ -1,9 +1,19 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python +__author__ = "bt3" -'''To use timeit you create a Timer object whose parameters are two Python statements. The first parameter is a Python statement that you want to time; the second parameter is a statement that will run once to set up the test. The timeit module will then time how long it takes to execute the statement some number of times. By default timeit will try to run the statement one million times. When its done it returns the time as a floating point value representing the total number of seconds. However, since it executes the statement a million times you can read the result as the number of microseconds to execute the test one time. You can also pass timeit a named parameter called number that allows you to specify how many times the test statement is executed. The following session shows how long it takes to run each of our test functions 1000 times. ''' +'''To use timeit you create a Timer object whose parameters are two Python +statements. The first parameter is a Python statement that you want to time; +the second parameter is a statement that will run once to set up the test. +The timeit module will then time how long it takes to execute the statement +some number of times. By default timeit will try to run the statement one +million times. When its done it returns the time as a floating point value +representing the total number of seconds. However, since it executes the +statement a million times you can read the result as the number of +microseconds to execute the test one time. You can also pass timeit a +named parameter called number that allows you to specify how many times the +test statement is executed. The following session shows how long it takes to +run each of our test functions 1000 times. ''' import timeit @@ -19,7 +29,7 @@ for i in range(10000,1000001,20000): print("%d,%10.3f,%10.3f" % (i, lst_time, d_time)) -""" There rersults are: +""" There results are: 10000, 0.192, 0.002 30000, 0.600, 0.002 50000, 1.000, 0.002 diff --git a/src/neat_builtin_examples/lists_and_strings/runtime_lists_with_timeit_module.py b/MY_BOOK/ebook_src/builtin_structures/runtime_lists_with_timeit_module.py old mode 100644 new mode 100755 similarity index 97% rename from src/neat_builtin_examples/lists_and_strings/runtime_lists_with_timeit_module.py rename to MY_BOOK/ebook_src/builtin_structures/runtime_lists_with_timeit_module.py index c9841bc..f7da733 --- a/src/neat_builtin_examples/lists_and_strings/runtime_lists_with_timeit_module.py +++ b/MY_BOOK/ebook_src/builtin_structures/runtime_lists_with_timeit_module.py @@ -1,7 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python +__author__ = "bt3" '''To use timeit you create a Timer object whose parameters are two Python statements. The first parameter is a Python statement that you want to time; the second parameter is a statement that will run once to set up the test. The timeit module will then time how long it takes to execute the statement some number of times. By default timeit will try to run the statement one million times. When its done it returns the time as a floating point value representing the total number of seconds. However, since it executes the statement a million times you can read the result as the number of microseconds to execute the test one time. You can also pass timeit a named parameter called number that allows you to specify how many times the test statement is executed. The following session shows how long it takes to run each of our test functions 1000 times. ''' diff --git a/src/neat_builtin_examples/numbers/search_entry_matrix.py b/MY_BOOK/ebook_src/builtin_structures/search_entry_matrix.py old mode 100644 new mode 100755 similarity index 72% rename from src/neat_builtin_examples/numbers/search_entry_matrix.py rename to MY_BOOK/ebook_src/builtin_structures/search_entry_matrix.py index 0ddd73b..6d70fdd --- a/src/neat_builtin_examples/numbers/search_entry_matrix.py +++ b/MY_BOOK/ebook_src/builtin_structures/search_entry_matrix.py @@ -1,18 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" +''' Search an Entry in a Matrix where the Rows and columns are Sorted + In this 2D matrix, every row is increasingly sorted from left to right, + and every column is increasingly sorted from top to bottom. + The runtime is O(m+n). +''' def find_elem_matrix_bool(m1, value): - ''' Search an Entry in a Matrix where the Rows and columns are Sorted - In this 2D matrix, every row is increasingly sorted from left to right, - and every column is increasingly sorted from top to bottom. - The runtime is O(m+n). ''' + found = False row = 0 col = len(m1[0]) - 1 + while row < len(m1) and col >= 0: + if m1[row][col] == value: found = True break @@ -20,8 +24,9 @@ def find_elem_matrix_bool(m1, value): col-=1 else: row+=1 + return found - + def test_find_elem_matrix_bool(module_name='this module'): @@ -30,9 +35,6 @@ def test_find_elem_matrix_bool(module_name='this module'): assert(find_elem_matrix_bool(m1,3) == False) m2 = [[0]] assert(find_elem_matrix_bool(m2,0) == True) - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) if __name__ == '__main__': diff --git a/src/neat_builtin_examples/lists_and_strings/simple_str_comprension.py b/MY_BOOK/ebook_src/builtin_structures/simple_str_comprension.py old mode 100644 new mode 100755 similarity index 54% rename from src/neat_builtin_examples/lists_and_strings/simple_str_comprension.py rename to MY_BOOK/ebook_src/builtin_structures/simple_str_comprension.py index d357e69..6a516df --- a/src/neat_builtin_examples/lists_and_strings/simple_str_comprension.py +++ b/MY_BOOK/ebook_src/builtin_structures/simple_str_comprension.py @@ -1,11 +1,19 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + - from collections import Counter + def str_comp(s): - ''' basic str compression with counts of repeated char''' + ''' + >>> s1 = 'aabcccccaaa' + >>> str_comp(s1) + 'a2b1c5a3' + >>> str_comp('') + '' + ''' + count, last = 1, '' list_aux = [] for i, c in enumerate(s): @@ -17,16 +25,10 @@ def str_comp(s): list_aux.append(c) count = 1 last = c - list_aux.append(str(count)) + list_aux.append(str(count)) return ''.join(list_aux) - -def main(): - s1 = 'aabcccccaaa' - s2 = '' - print(str_comp(s1)) # 'a2b1c5a3' - print(str_comp(s2)) - + if __name__ == '__main__': - main() - + import doctest + doctest.testmod() diff --git a/MY_BOOK/ebook_src/builtin_structures/sum_two_numbers_as_strings.py b/MY_BOOK/ebook_src/builtin_structures/sum_two_numbers_as_strings.py new file mode 100755 index 0000000..ec05a14 --- /dev/null +++ b/MY_BOOK/ebook_src/builtin_structures/sum_two_numbers_as_strings.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' +find the sum of two integers represented as strings, +return the sum as string, i.e "123" and "456" would return "579" +''' + + +def get_number(s): + count = 1 + num = 0 + p = len(s) -1 + while p >= 0: + num = num + int(s[p])*count + count *= 10 + p -= 1 + return num + + +def sum_string(s1, s2): + ''' + >>> sum_string('10', '5') + '15' + >>> sum_string('0', '1') + '1' + >>> sum_string('123', '456') + '579' + ''' + + n1 = get_number(s1) + n2 = get_number(s2) + return str(n2 + n1) + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/src/neat_builtin_examples/dicts/__init__.py b/MY_BOOK/ebook_src/dynamic_programming/__init__.py similarity index 100% rename from src/neat_builtin_examples/dicts/__init__.py rename to MY_BOOK/ebook_src/dynamic_programming/__init__.py diff --git a/src/programming_paradigms/dynamic_programming/memo.py b/MY_BOOK/ebook_src/dynamic_programming/memo.py similarity index 90% rename from src/programming_paradigms/dynamic_programming/memo.py rename to MY_BOOK/ebook_src/dynamic_programming/memo.py index 7391a6c..adff8e2 100644 --- a/src/programming_paradigms/dynamic_programming/memo.py +++ b/MY_BOOK/ebook_src/dynamic_programming/memo.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail + +__author__ = "bt3" from functools import wraps @@ -20,7 +20,7 @@ def memo(func): def find_fibonacci_seq_rec(n): ''' implements the nth fibonacci value in a recursive exponential runtime ''' if n < 2: return n - return find_fibonacci_seq_rec(n - 1) + find_fibonacci_seq_rec(n - 2) + return find_fibonacci_seq_rec(n - 1) + find_fibonacci_seq_rec(n - 2) def test_memo(): n = 50 @@ -31,9 +31,9 @@ def test_memo(): if __name__ == '__main__': test_memo() - - - + + + diff --git a/src/programming_paradigms/dynamic_programming/memoized_longest_inc_subseq.py b/MY_BOOK/ebook_src/dynamic_programming/memoized_longest_inc_subseq.py similarity index 89% rename from src/programming_paradigms/dynamic_programming/memoized_longest_inc_subseq.py rename to MY_BOOK/ebook_src/dynamic_programming/memoized_longest_inc_subseq.py index 7547caa..4e6434c 100644 --- a/src/programming_paradigms/dynamic_programming/memoized_longest_inc_subseq.py +++ b/MY_BOOK/ebook_src/dynamic_programming/memoized_longest_inc_subseq.py @@ -1,7 +1,6 @@ #!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +__author__ = "bt3" from itertools import combinations from bisect import bisect @@ -14,7 +13,7 @@ def naive_longest_inc_subseq(seq): for sub in combinations(seq, length): if list(sub) == sorted(sub): return len(sub) - + def longest_inc_subseq1(seq): ''' an iterative algorithm for the longest increasing subsequence problem ''' @@ -24,8 +23,8 @@ def longest_inc_subseq1(seq): if idx == len(end): end.append(val) else: end[idx] = val return len(end) - - + + def longest_inc_subseq2(seq): ''' another iterative algorithm for the longest increasing subsequence problem ''' L = [1] * len(seq) @@ -51,17 +50,17 @@ def memoized_longest_inc_subseq(seq): @benchmark def test_naive_longest_inc_subseq(): print(naive_longest_inc_subseq(s1)) - + benchmark -def test_longest_inc_subseq1(): +def test_longest_inc_subseq1(): print(longest_inc_subseq1(s1)) @benchmark -def test_longest_inc_subseq2(): +def test_longest_inc_subseq2(): print(longest_inc_subseq2(s1)) - + @benchmark -def test_memoized_longest_inc_subseq(): +def test_memoized_longest_inc_subseq(): print(memoized_longest_inc_subseq(s1)) @@ -73,9 +72,9 @@ if __name__ == '__main__': test_longest_inc_subseq1() test_longest_inc_subseq2() test_memoized_longest_inc_subseq() - - - + + + diff --git a/src/programming_paradigms/modules/change_ext_file.py b/MY_BOOK/ebook_src/manipulating_files/change_ext_file.py similarity index 64% rename from src/programming_paradigms/modules/change_ext_file.py rename to MY_BOOK/ebook_src/manipulating_files/change_ext_file.py index e5b9d7a..f114c2e 100644 --- a/src/programming_paradigms/modules/change_ext_file.py +++ b/MY_BOOK/ebook_src/manipulating_files/change_ext_file.py @@ -1,6 +1,8 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + + +__author__ = "bt3" + import os import sys @@ -12,12 +14,12 @@ def change_file_ext(): print("Usage: change_ext.py filename.old_ext 'new_ext'") sys.exit() - name = os.path.splitext(sys.argv[1])[0] + "." + sys.argv[2] + name = os.path.splitext(sys.argv[1])[0] + "." + sys.argv[2] print (name) - + try: - shutil.copyfile(sys.argv[1], name) - except OSError as err: + shutil.copyfile(sys.argv[1], name) + except OSError as err: print (err) diff --git a/src/neat_builtin_examples/lists_and_strings/count_unique_words.py b/MY_BOOK/ebook_src/manipulating_files/count_unique_words_files.py old mode 100644 new mode 100755 similarity index 52% rename from src/neat_builtin_examples/lists_and_strings/count_unique_words.py rename to MY_BOOK/ebook_src/manipulating_files/count_unique_words_files.py index 9ab81a2..e1e3de0 --- a/src/neat_builtin_examples/lists_and_strings/count_unique_words.py +++ b/MY_BOOK/ebook_src/manipulating_files/count_unique_words_files.py @@ -1,24 +1,28 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/python +__author__ = "bt3" + + +import collections import string import sys -def count_unique_word(): - ''' list every word and number of times in alphabetical order for input files ''' - words = {} # create an empty dictionary - strip = string.whitespace + string.punctuation + string.digits + "\"'" +def count_unique_word_file(): + if len(sys.argv) < 2: + print "Usage: python count_unique_word.py NAMEFILE" + + words = collections.defaultdict(int) + strip = string.whitespace + string.punctuation + string.digits + "\"'" for filename in sys.argv[1:]: with open(filename) as file: - for line in file: + for line in file: for word in line.lower().split(): word = word.strip(strip) if len(word) > 2: - words[word] = words.get(word,0) +1 + words[word] = +1 for word in sorted(words): print("'{0}' occurs {1} times.".format(word, words[word])) -count_unique_word() - +if __name__ == '__main__': + count_unique_word_file() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/manipulating_files/count_unique_words_frequency.py b/MY_BOOK/ebook_src/manipulating_files/count_unique_words_frequency.py new file mode 100755 index 0000000..14162d5 --- /dev/null +++ b/MY_BOOK/ebook_src/manipulating_files/count_unique_words_frequency.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +__author__ = "bt3" + + +import collections +import sys + +def count_unique_word_freq(): + return collections.Counter(\ + sys.stdin.read().lower().split()).most_common(n) + + +if __name__ == '__main__': + count_unique_word_freq() \ No newline at end of file diff --git a/src/programming_paradigms/modules/grep_word_from_files.py b/MY_BOOK/ebook_src/manipulating_files/grep_word_from_files.py similarity index 87% rename from src/programming_paradigms/modules/grep_word_from_files.py rename to MY_BOOK/ebook_src/manipulating_files/grep_word_from_files.py index 6ef2a81..7dfa064 100644 --- a/src/programming_paradigms/modules/grep_word_from_files.py +++ b/MY_BOOK/ebook_src/manipulating_files/grep_word_from_files.py @@ -1,6 +1,7 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + + +__author__ = "bt3" import sys @@ -13,7 +14,7 @@ def grep_word_from_files(): if word in line: print("{0}:{1}:{2:.40}".format(filename, lino, line.rstrip())) - + if __name__ == '__main__': if len(sys.argv) < 2: print("Usage: grep_word_from_files.py word infile1 [infile2...]") diff --git a/src/programming_paradigms/modules/remove_blank_lines.py b/MY_BOOK/ebook_src/manipulating_files/remove_blank_lines.py similarity index 91% rename from src/programming_paradigms/modules/remove_blank_lines.py rename to MY_BOOK/ebook_src/manipulating_files/remove_blank_lines.py index 4576434..e9bad3f 100644 --- a/src/programming_paradigms/modules/remove_blank_lines.py +++ b/MY_BOOK/ebook_src/manipulating_files/remove_blank_lines.py @@ -1,6 +1,7 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + + +__author__ = "bt3" @@ -46,8 +47,8 @@ def remove_blank_lines(): lines = read_data(filename) if lines: write_data(lines, filename) - - + + if __name__ == '__main__': remove_blank_lines() diff --git a/src/neat_builtin_examples/dicts/OrderedDict_example.py b/MY_BOOK/ebook_src/python_examples/example_OrderedDict.py similarity index 75% rename from src/neat_builtin_examples/dicts/OrderedDict_example.py rename to MY_BOOK/ebook_src/python_examples/example_OrderedDict.py index b7dbef1..89d3291 100644 --- a/src/neat_builtin_examples/dicts/OrderedDict_example.py +++ b/MY_BOOK/ebook_src/python_examples/example_OrderedDict.py @@ -1,17 +1,17 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" from collections import OrderedDict def OrderedDict_example(): - ''' show some examples for OrderedDict ''' - ''' keep the order of insertion. + ''' show some examples for OrderedDict ''' + ''' keep the order of insertion. maintains a doubly linked list, so size is more than twice than normal dict''' - + pairs = [('a', 1), ('b',2), ('c',3)] - + d1 = {} for key, value in pairs: if key not in d1: diff --git a/MY_BOOK/ebook_src/python_examples/example_args.py b/MY_BOOK/ebook_src/python_examples/example_args.py new file mode 100755 index 0000000..299035b --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_args.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +def simple2(a, *args): + print args + +def simple(*args): + print args + +def simple3(**kwargs): + print kwargs + + +simple(1, 2, 3) +simple2(1, 2, 3) +simple3(x=1, y=2) diff --git a/src/programming_paradigms/modules/do_benchmark.py b/MY_BOOK/ebook_src/python_examples/example_benchmark_decorator.py similarity index 80% rename from src/programming_paradigms/modules/do_benchmark.py rename to MY_BOOK/ebook_src/python_examples/example_benchmark_decorator.py index bfe97a5..749e403 100644 --- a/src/programming_paradigms/modules/do_benchmark.py +++ b/MY_BOOK/ebook_src/python_examples/example_benchmark_decorator.py @@ -1,8 +1,10 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + import random + def benchmark(func): import time def wrapper(*args, **kwargs): @@ -11,15 +13,16 @@ def benchmark(func): print("\t%s" % func.__name__, time.clock()-t) return res return wrapper - + + @benchmark def random_tree(n): temp = [n for n in range(n)] for i in range(n+1): temp[random.choice(temp)] = random.choice(temp) return temp - + if __name__ == '__main__': - random_tree(10000) + random_tree(10000) diff --git a/src/programming_paradigms/oop/ShapeClass.py b/MY_BOOK/ebook_src/python_examples/example_class.py similarity index 100% rename from src/programming_paradigms/oop/ShapeClass.py rename to MY_BOOK/ebook_src/python_examples/example_class.py diff --git a/MY_BOOK/ebook_src/python_examples/example_comp_lists.py b/MY_BOOK/ebook_src/python_examples/example_comp_lists.py new file mode 100644 index 0000000..f5c641c --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_comp_lists.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +a = [3, 4, 5, 6, 7] + + +# Filter elements greater than 4 + +# Bad: + +b = [] +for i in a: + if i > 4: + b.append(i) +print b + +# Good: +print [i for i in a if i > 4] + +# Or: +print filter(lambda x: x > 4, a) + + +# Add three to all list members: + +# Bad +b = [] +for i in range(len(a)): + b.append(a[i] + 3) +print b + +# Good: +print [i + 3 for i in a] + +# Or: +print map(lambda i: i + 3, a) \ No newline at end of file diff --git a/src/neat_builtin_examples/dicts/Counter_example.py b/MY_BOOK/ebook_src/python_examples/example_counter.py similarity index 74% rename from src/neat_builtin_examples/dicts/Counter_example.py rename to MY_BOOK/ebook_src/python_examples/example_counter.py index b0f3284..bd233e3 100644 --- a/src/neat_builtin_examples/dicts/Counter_example.py +++ b/MY_BOOK/ebook_src/python_examples/example_counter.py @@ -1,32 +1,31 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" from collections import Counter def Counter_example(): - ''' show some examples for Counter ''' - ''' it is a dictionary that maps the items to the number of occurences ''' + ''' it is a dictionary that maps the items to the number of occurrences ''' seq1 = [1, 2, 3, 5, 1, 2, 5, 5, 2, 5, 1, 4] seq_counts = Counter(seq1) print(seq_counts) - + ''' we can increment manually or use the update() method ''' seq2 = [1, 2, 3] seq_counts.update(seq2) print(seq_counts) - + seq3 = [1, 4, 3] for key in seq3: seq_counts[key] += 1 print(seq_counts) - + ''' also, we can use set operations such as a-b or a+b ''' seq_counts_2 = Counter(seq3) - print(seq_counts_2) - print(seq_counts + seq_counts_2) + print(seq_counts_2) + print(seq_counts + seq_counts_2) print(seq_counts - seq_counts_2) - + if __name__ == '__main__': Counter_example() diff --git a/MY_BOOK/ebook_src/python_examples/example_decorator.py b/MY_BOOK/ebook_src/python_examples/example_decorator.py new file mode 100644 index 0000000..8ef04f3 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_decorator.py @@ -0,0 +1,19 @@ +#!/bin/python +# +# An example of Python Decorator +# + +def pretty_sumab(func): + def inner(a,b): + print(str(a) + " + " + str(b) + " is ", end="") + return func(a,b) + + return inner + +@pretty_sumab +def sumab(a,b): + summed = a + b + print(summed) + +if __name__ == "__main__": + sumab(5,3) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/python_examples/example_decorators.py b/MY_BOOK/ebook_src/python_examples/example_decorators.py new file mode 100755 index 0000000..a64b299 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_decorators.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +def logger(func): + def inner(*args): #1 + print "Arguments were: {0}".format(args) + return func(*args) + return inner + +@logger +def foo(x, y): + return x+y + +print foo(1, 2) + + +def sum(func): + s = 0 + for i in func(): + s += i + return s + +@sum +def interate(): + a = [] + for i in range(10): + a.append(i) + return a + +print interate + +# which is the same as +def interate(): + a = [] + for i in range(10): + a.append(i) + return a + +print sum(interate) \ No newline at end of file diff --git a/src/neat_builtin_examples/dicts/defaultdict_example.py b/MY_BOOK/ebook_src/python_examples/example_defaultdict.py similarity index 68% rename from src/neat_builtin_examples/dicts/defaultdict_example.py rename to MY_BOOK/ebook_src/python_examples/example_defaultdict.py index cea9d1c..6db52b7 100644 --- a/src/neat_builtin_examples/dicts/defaultdict_example.py +++ b/MY_BOOK/ebook_src/python_examples/example_defaultdict.py @@ -1,13 +1,13 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" from collections import defaultdict def defaultdict_example(): - ''' show some examples for defaultdicts ''' - pairs = {('a', 1), ('b',2), ('c',3)} - + ''' show some examples for defaultdicts ''' + pairs = {('a', 1), ('b',2), ('c',3)} + d1 = {} for key, value in pairs: if key not in d1: diff --git a/MY_BOOK/ebook_src/python_examples/example_doctest.py b/MY_BOOK/ebook_src/python_examples/example_doctest.py new file mode 100644 index 0000000..3c379bc --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_doctest.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +__author__ = "bt3" + +''' +The doctest module automatically runs any statement beginning with >>> +and compares the following line with the output from the interpreter. + +>>> 1 == 1 +False +''' + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/src/neat_builtin_examples/numbers/testing_floats.py b/MY_BOOK/ebook_src/python_examples/example_fractions.py similarity index 88% rename from src/neat_builtin_examples/numbers/testing_floats.py rename to MY_BOOK/ebook_src/python_examples/example_fractions.py index 5734170..9bbff22 100644 --- a/src/neat_builtin_examples/numbers/testing_floats.py +++ b/MY_BOOK/ebook_src/python_examples/example_fractions.py @@ -1,22 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + from fractions import Fraction def rounding_floats(number1, places): - ''' some operations with float()''' return round(number1, places) def float_to_fractions(number): return Fraction(*number.as_integer_ratio()) - + def get_denominator(number1, number2): a = Fraction(number1, number2) return a.denominator - + def get_numerator(number1, number2): a = Fraction(number1, number2) @@ -34,7 +34,7 @@ def test_testing_floats(module_name='this module'): assert(float_to_fractions(number1) == number4) assert(get_denominator(number2, number6) == number6) assert(get_numerator(number2, number6) == number2) - + s = 'Tests in {name} have {con}!' print(s.format(name=module_name, con='passed')) diff --git a/MY_BOOK/ebook_src/python_examples/example_generator.py b/MY_BOOK/ebook_src/python_examples/example_generator.py new file mode 100644 index 0000000..8256b90 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_generator.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def interate(x): + for i in range(x): + yield i + +def gen1(): + a = interate(10) + print a.next() + print a.next() + print a.next() + + +def reverse(data): + for i in range(len(data)-1, -1, -1): + yield data[i] + +def gen2(): + for c in reverse('awesome'): + print c + +if __name__ == '__main__': + gen1() + gen2() diff --git a/MY_BOOK/ebook_src/python_examples/example_lambda.py b/MY_BOOK/ebook_src/python_examples/example_lambda.py new file mode 100644 index 0000000..34ddec3 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_lambda.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +test = lambda x: x**2 +print test(3) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/python_examples/example_logging.py b/MY_BOOK/ebook_src/python_examples/example_logging.py new file mode 100644 index 0000000..5d483fe --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_logging.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +import logging + +LOG_FILENAME = 'logging_example.out' +logging.basicConfig(filename=LOG_FILENAME, + level=logging.DEBUG, + ) + +logging.debug('This message should go to the log file') + +f = open(LOG_FILENAME, 'rt') +try: + body = f.read() +finally: + f.close() + +print 'FILE:' +print body \ No newline at end of file diff --git a/MY_BOOK/ebook_src/python_examples/example_lru_cache.py b/MY_BOOK/ebook_src/python_examples/example_lru_cache.py new file mode 100644 index 0000000..11b451e --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_lru_cache.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +__author__ = "bt3" + + +from functools import lru_cache + + +@lru_cache(maxsize=20) +def fib(n): + if n < 2: + return n + return fib(n-1) + fib(n-2) + + +if __name__ == '__main__': + print([fib(n) for n in range(10)]) + print(fib.cache_info()) diff --git a/src/neat_builtin_examples/numbers/testing_numpy.py b/MY_BOOK/ebook_src/python_examples/example_numpy.py similarity index 54% rename from src/neat_builtin_examples/numbers/testing_numpy.py rename to MY_BOOK/ebook_src/python_examples/example_numpy.py index bbd3fae..a2a90a6 100644 --- a/src/neat_builtin_examples/numbers/testing_numpy.py +++ b/MY_BOOK/ebook_src/python_examples/example_numpy.py @@ -1,7 +1,9 @@ -#!/usr/bin/python -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + +import time import numpy as np def testing_numpy(): @@ -15,11 +17,11 @@ def testing_numpy(): print(np.cos(ax)) print(ax-ay) print(np.where(ax<2, ax, 10)) - + m = np.matrix([ax, ay, ax]) print(m) print(m.T) - + grid1 = np.zeros(shape=(10,10), dtype=float) grid2 = np.ones(shape=(10,10), dtype=float) print(grid1) @@ -27,6 +29,32 @@ def testing_numpy(): print(grid1[1]+10) print(grid2[:,2]*2) + +def trad_version(): + t1 = time.time() + X = range(10000000) + Y = range(10000000) + Z = [] + for i in range(len(X)): + Z.append(X[i] + Y[i]) + return time.time() - t1 + +def numpy_version(): + t1 = time.time() + X = np.arange(10000000) + Y = np.arange(10000000) + Z = X + Y + return time.time() - t1 + + + if __name__ == '__main__': testing_numpy() + print(trad_version()) + print(numpy_version()) + +''' +3.23564291 +0.0714290142059 +''' diff --git a/MY_BOOK/ebook_src/python_examples/example_open_files.py b/MY_BOOK/ebook_src/python_examples/example_open_files.py new file mode 100644 index 0000000..28d03e6 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_open_files.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +filename = raw_input('Enter a file name: ') +try: + f = open(filename, "r") +except: + print 'There is no file named', filename + diff --git a/src/programming_paradigms/modules/export_pickle.py b/MY_BOOK/ebook_src/python_examples/example_pickle.py similarity index 51% rename from src/programming_paradigms/modules/export_pickle.py rename to MY_BOOK/ebook_src/python_examples/example_pickle.py index b26bde8..2a863ee 100644 --- a/src/programming_paradigms/modules/export_pickle.py +++ b/MY_BOOK/ebook_src/python_examples/example_pickle.py @@ -1,33 +1,58 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + import pickle +def import_pickle(filename): + fh = None + try: + fh = open(filename, "rb") + mydict2 = pickle.load(fh) + return mydict2 + + except (EnvironmentError) as err: + print ("{0}: import error: {0}".format(os.path.basename(sys.arg[0]), err)) + return false + + finally: + if fh is not None: + fh.close() + + +def test_import_pickle(): + pkl_file = 'test.dat' + mydict = import_pickle(pkl_file) + print(mydict) + + + def export_pickle(data, filename='test.dat', compress=False): - """ simple example of how to use pickle to export files """ + fh = None try: if compress: fh = gzip.open(filename, "wb") # write binary else: - fh = open(filename, "wb") # compact binary pickle format - pickle.dump(data, fh, pickle.HIGHEST_PROTOCOL) - + fh = open(filename, "wb") # compact binary pickle format + pickle.dump(data, fh, pickle.HIGHEST_PROTOCOL) + except(EnvironmentError, pickle.PickingError) as err: print("{0}: export error: {1}".format(os.path.basename(sys.argv[0], err))) return False - + finally: if fh is not None: fh.close() - + def test_export_pickle(): mydict = {'a': 1, 'b': 2, 'c': 3} export_pickle(mydict) - - + + if __name__ == '__main__': test_export_pickle() + test_import_pickle() diff --git a/MY_BOOK/ebook_src/python_examples/example_queue.py b/MY_BOOK/ebook_src/python_examples/example_queue.py new file mode 100755 index 0000000..b51548f --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_queue.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +import Queue + +q = Queue.Queue() + +for i in range(10): + q.put(i) + +for i in range(10): + print q.get(i) diff --git a/src/neat_builtin_examples/numbers/testing_random.py b/MY_BOOK/ebook_src/python_examples/example_random.py similarity index 86% rename from src/neat_builtin_examples/numbers/testing_random.py rename to MY_BOOK/ebook_src/python_examples/example_random.py index dae8767..e4dc921 100644 --- a/src/neat_builtin_examples/numbers/testing_random.py +++ b/MY_BOOK/ebook_src/python_examples/example_random.py @@ -1,6 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" import random @@ -12,11 +12,11 @@ def testing_random(): print(random.choice(values)) print(random.sample(values, 2)) print(random.sample(values, 3)) - + ''' shuffle in place ''' random.shuffle(values) print(values) - + ''' create random integers ''' print(random.randint(0,10)) print(random.randint(0,10)) diff --git a/src/neat_builtin_examples/dicts/setdeault_example.py b/MY_BOOK/ebook_src/python_examples/example_setdefault.py similarity index 90% rename from src/neat_builtin_examples/dicts/setdeault_example.py rename to MY_BOOK/ebook_src/python_examples/example_setdefault.py index 55dbfd4..6ad5c56 100644 --- a/src/neat_builtin_examples/dicts/setdeault_example.py +++ b/MY_BOOK/ebook_src/python_examples/example_setdefault.py @@ -1,6 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" def usual_dict(dict_data): @@ -28,7 +28,7 @@ def test_setdef(module_name='this module'): ('key2', 'value5'),) print(usual_dict(dict_data)) print(setdefault_dict(dict_data)) - + s = 'Tests in {name} have {con}!' print(s.format(name=module_name, con='passed')) diff --git a/src/neat_builtin_examples/sets/set_operations_with_lists.py b/MY_BOOK/ebook_src/python_examples/example_sets.py similarity index 92% rename from src/neat_builtin_examples/sets/set_operations_with_lists.py rename to MY_BOOK/ebook_src/python_examples/example_sets.py index f836d21..ef621d4 100644 --- a/src/neat_builtin_examples/sets/set_operations_with_lists.py +++ b/MY_BOOK/ebook_src/python_examples/example_sets.py @@ -1,6 +1,6 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" def difference(l1): """ return the list with duplicate elements removed """ diff --git a/MY_BOOK/ebook_src/python_examples/example_socket.py b/MY_BOOK/ebook_src/python_examples/example_socket.py new file mode 100644 index 0000000..0810498 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_socket.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + + +__author__ = "bt3" + + +import socket + + +def netcat(hostname, port, content): + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + s.connect((hostname, port)) + s.sendall(content) + + adata = [] + while 1: + data = s.recv(1024) + if data == '': + break + adata.append(data) + + s.close() + return adata + + + +if __name__ == '__main__': + + PORT = 12345 + HOSTNAME = '54.209.5.48' + + message = netcat(HOSTNAME, PORT, 'Hello!')[1] + print message \ No newline at end of file diff --git a/MY_BOOK/ebook_src/python_examples/example_string_format.py b/MY_BOOK/ebook_src/python_examples/example_string_format.py new file mode 100644 index 0000000..b13add5 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_string_format.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +foo = 'foo' +bar = 'bar' + +print '%s%s' % (foo, bar) # It is OK +print '{0}{1}'.format(foo, bar) # It is better +print '{foo}{bar}'.format(foo=foo, bar=bar) # It is best \ No newline at end of file diff --git a/MY_BOOK/ebook_src/python_examples/example_subprocess.py b/MY_BOOK/ebook_src/python_examples/example_subprocess.py new file mode 100644 index 0000000..b845ca4 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_subprocess.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +import subprocess,os + +os.system('ls') +subprocess.call(['ls', '-1'], shell=True) diff --git a/MY_BOOK/ebook_src/python_examples/example_telnet.py b/MY_BOOK/ebook_src/python_examples/example_telnet.py new file mode 100644 index 0000000..2c46254 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_telnet.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + + +__author__ = "bt3" + + +from telnetlib import Telnet + + +# examples of telnet connections +PORT = 12345 +HOST = '54.209.5.48' + +# creating connection +tn = Telnet(HOST ,PORT) + +# reading input +msg_in2 = tn.read_all().dec_msg() +tn.read_until(b'psifer text: ') + +# writing outputs +tn.write(msg.encode() + b'\n') diff --git a/MY_BOOK/ebook_src/python_examples/example_testing.py b/MY_BOOK/ebook_src/python_examples/example_testing.py new file mode 100644 index 0000000..5e900f2 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_testing.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + + +def test_doctest(): + ''' + >>> 1 == 1 + False + ''' + pass + +if __name__ == '__main__': + import doctest + doctest.testmod() + +##### + +import unittest + +class BasicsTestCase(unittest.TestCase): + + def test_find_name(self): + self.assertTrue(1 == 1) + self.assertFalse(1 == 2) + +if __name__ == '__main__': + unittest.main() + + + +##### + +# content of test_example.py, run with $ py.test +# +# run tests over the directory +# $ nosetest + + +def func(x): + return x + 1 + +def test_answer(): + assert func(3) == 4 + diff --git a/MY_BOOK/ebook_src/python_examples/example_threads.py b/MY_BOOK/ebook_src/python_examples/example_threads.py new file mode 100644 index 0000000..8d44859 --- /dev/null +++ b/MY_BOOK/ebook_src/python_examples/example_threads.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +import threading + +def worker(num): + """thread worker function""" + print 'Worker: %s' % num + return + +threads = [] +for i in range(5): + t = threading.Thread(target=worker, args=(i,)) + threads.append(t) + t.start() \ No newline at end of file diff --git a/src/programming_paradigms/modules/using_time_module.py b/MY_BOOK/ebook_src/python_examples/example_time.py similarity index 73% rename from src/programming_paradigms/modules/using_time_module.py rename to MY_BOOK/ebook_src/python_examples/example_time.py index 027bbfe..78bada7 100644 --- a/src/programming_paradigms/modules/using_time_module.py +++ b/MY_BOOK/ebook_src/python_examples/example_time.py @@ -1,11 +1,12 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/python + +__author__ = "bt3" + +''' a simple example of how to time a function ''' import time def sumOfN2(n): - ''' a simple example of how to time a function ''' start = time.time() theSum = 0 for i in range(1,n+1): diff --git a/MY_BOOK/ebook_src/real_interview_problems/2n_packets.py b/MY_BOOK/ebook_src/real_interview_problems/2n_packets.py new file mode 100644 index 0000000..e8d5eb0 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/2n_packets.py @@ -0,0 +1,41 @@ +#!/bin/python + +import math +import os +import random +import re +import sys + +# Complete the 'largestRepackaged' function below. +# +# The function is expected to return a LONG_INTEGER. +# The function accepts INTEGER_ARRAY arrivingPackets as parameter. +# + +def largestRepackaged(arrivingPackets): + + packet_size = arrivingPackets[0] + packets = arrivingPackets[1:] + largest_packet = 0 + remaining = 0 + + for packet in packets: + print packet + if remaining: + packet += remaining + remaining = 0 + + if packet % 2 != 0: + remaining = packet % 2 + packet -= remaining + + if packet > largest_packet: + largest_packet = packet + + return largest_packet + + +if __name__ == '__main__': + arrivingPackets= [5, 1, 2, 4, 7, 5] + + print(largestRepackaged(arrivingPackets)) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/balanced.py b/MY_BOOK/ebook_src/real_interview_problems/balanced.py new file mode 100644 index 0000000..760316d --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/balanced.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def balance_par_str_with_stack(str1): + i, stack = 0, [] + + while i < len(str1): + symbol = str1[i] + if symbol == "(": + stack.append(symbol) + elif symbol == ")": + stack.pop() + i += 1 + return not stack + + + +if __name__ == '__main__': + print(balance_par_str_with_stack('((()))')) + print(balance_par_str_with_stack('(()')) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/binary_search.py b/MY_BOOK/ebook_src/real_interview_problems/binary_search.py new file mode 100644 index 0000000..c9f7705 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/binary_search.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +def binary_search(array, value): + last, first = len(array), 0 + + while first < last: + mid = (last - first)//2 + item = array[mid] + + if item == value: + return True + + elif item < value: + last = mid + + else: + first = mid + + return False + +def binary_search_rec(array, value, first=0, last=None): + last = last or len(array) + if len(array[first:last]) < 1: + return False + + mid = (last - first)//2 + if array[mid] == value: + return True + elif array[mid] < value: + return binary_search_rec(array, value, first=first, last=mid) + else: + return binary_search_rec(array, value, first=mid, last=last) + + +if __name__ == '__main__': + array = [3, 4, 6, 7, 10, 11, 34, 67, 84] + value = 6 + assert(binary_search(array, value) == True) + assert(binary_search_rec(array, value) == True) + value = 8 + assert(binary_search(array, value) == False) + assert(binary_search_rec(array, value) == False) + array = [8] + assert(binary_search(array, value) == True) + assert(binary_search_rec(array, value) == True) + array = [] + assert(binary_search(array, value) == False) + assert(binary_search_rec(array, value) == False) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/bst.py b/MY_BOOK/ebook_src/real_interview_problems/bst.py new file mode 100644 index 0000000..f908e10 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/bst.py @@ -0,0 +1,165 @@ +#!/usr/bin/python + +__author__ = "bt3" + +from collections import deque + +class Node(object): + + def __init__(self, item=None): + + self.item = item + self.left = None + self.right = None + + + def _add(self, value): + new_node = Node(value) + if not self.item: + self.item = new_node + else: + if value > self.item: + self.right = self.right and self.right._add(value) or new_node + elif value < self.item: + self.left = self.left and self.left._add(value) or new_node + else: + print("BSTs do not support repeated items.") + return self + + + def _search(self, value): + if self.item == value: + return True + elif self.left and value < self.item: + return self.left._search(value) + elif self.right and value > self.item: + return self.right._search(value) + else: + return False + + + def _isLeaf(self): + return not self.right and not self.left + + + def _printPreorder(self): + print self.item + + if self.left: + self.left._printPreorder() + + if self.right: + self.right._printPreorder() + + + def _preorder_array(self): + nodes = [] + if self.item: + nodes.append(self.item) + if self.left: + nodes.extend(self.left._preorder_array()) + if self.right: + nodes.extend(self.right._preorder_array()) + return nodes + + + +class BST(object): + + def __init__(self): + self.root = None + + def add(self, value): + if not self.root: + self.root = Node(value) + else: + self.root._add(value) + + def printPreorder(self): + if self.root: + self.root._printPreorder() + + def search(self, value): + if self.root: + return self.root._search(value) + + def preorder_array(self): + if self.root: + return self.root._preorder_array() + else: + return 'Tree is empty.' + + + + +def BFT(tree): + current = tree.root + nodes = [] + queue = deque() + queue.append(current) + + while queue: + current = queue.popleft() + nodes.append(current.item) + if current.left: + queue.append(current.left) + if current.right: + queue.append(current.right) + + return nodes + + +def preorder(tree, nodes=None): + nodes = nodes or [] + if tree: + nodes.append(tree.item) + if tree.left: + preorder(tree.left, nodes) + if tree.right: + preorder(tree.right, nodes) + return nodes + + +def postorder(tree, nodes=None): + nodes = nodes or [] + if tree: + if tree.left: + nodes = postorder(tree.left, nodes) + if tree.right: + nodes = postorder(tree.right, nodes) + nodes.append(tree.item) + + return nodes + + +def inorder(tree, nodes=None): + nodes = nodes or [] + if tree: + if tree.left: + nodes = inorder(tree.left, nodes) + nodes.append(tree.item) + if tree.right: + nodes = inorder(tree.right, nodes) + return nodes + + + + +if __name__ == '__main__': + bst = BST() + l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] + for i in l: + bst.add(i) + + print + print "Searching for nodes 16 and 6:" + print bst.search(16) + print bst.search(6) + + print + print 'Traversals:' + print 'Original: ', l + print 'Preorder: ', preorder(bst.root) + print 'Postorder: ', postorder(bst.root) + print 'Inorder: ', inorder(bst.root) + print 'BSF: ', BFT(bst) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/check_anagram.py b/MY_BOOK/ebook_src/real_interview_problems/check_anagram.py new file mode 100644 index 0000000..f6bf749 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/check_anagram.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +from collections import Counter + +def check_if_anagram(word1, word2): + counter = Counter() + + for c in word1: + counter[c] += 1 + + for c in word2: + counter[c] -= 1 + + for values in counter.values(): + if values != 0: + return False + + return True + + + +if __name__ == '__main__': + word1 = 'abc' + word2 = 'bca' + assert(check_if_anagram(word1, word2) == True) + + word2 = 'bcd' + assert(check_if_anagram(word1, word2) == False) + + word1 = '' + word2 = '' + assert(check_if_anagram(word1, word2) == True) + + word1 = 'a' + word2 = 'a' + assert(check_if_anagram(word1, word2) == True) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/combination.py b/MY_BOOK/ebook_src/real_interview_problems/combination.py new file mode 100644 index 0000000..cdf3ba8 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/combination.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +def combination(array): + if len(array) < 2: + return set(array) + + result = set() + for index, item in enumerate(array): + new_array = array[:index] + array[index+1:] + result.add(item) + for perm in combination(new_array): + new_item = ''.join(sorted(item + perm)) + result.add(new_item) + + return result + + + +if __name__ == '__main__': + array = ['a', 'b', 'c'] + result = set(['a', 'ac', 'ab', 'abc', 'bc', 'c', 'b']) + assert(combination(array) == result) + + array = [''] + result = set(['']) + assert(combination(array) == result) + + array = ['a'] + result = set(['a']) + assert(combination(array) == result) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/hash_table.py b/MY_BOOK/ebook_src/real_interview_problems/hash_table.py new file mode 100644 index 0000000..70ff62d --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/hash_table.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +class HashTable(object): + def __init__(self, slots=10): + self.slots = slots + self.table = [] + self.create_table() + + # Get the slot + def hash_key(self, value): + return hash(value)%self.slots + + # When creating the table, add list struct + # to each slot + def create_table(self): + for i in range(self.slots): + self.table.append([]) + + # Method to add a item in the right slot + def add_item(self, value): + key = self.hash_key(value) + self.table[key].append(value) + + # Aux: print table + def print_table(self): + for key in range(self.slots): + print "Key is {0}, value is {1}.".format(key, self.table[key]) + + # Aux: find item + def find_item(self, item): + item_hash = self.hash_key(item) + return item in self.table[item_hash] + + +if __name__ == '__main__': + dic = HashTable(5) + for i in range(1, 40, 2): + dic.add_item(i) + + dic.print_table() + assert(dic.find_item(20) == False) + assert(dic.find_item(21) == True) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/linked_list.py b/MY_BOOK/ebook_src/real_interview_problems/linked_list.py new file mode 100644 index 0000000..0abf3e6 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/linked_list.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +class Node(object): + def __init__(self, value, next=None): + self.value = value + self.next = next + + +class LinkedList(object): + def __init__(self): + self.head = None + + def _add(self, value): + self.head = Node(value, self.head) + + def _printList(self): + node = self.head + while node: + print node.value + node = node.next + + def _find(self, index): + prev = None + node = self.head + i = 0 + while node and i < index: + prev = node + node = node.next + i += 1 + return node, prev, i + + def _delete(self, prev, node): + if not prev: + self.head = node.next + else: + prev.next = node.next + + def deleteNode(self, index): + node, prev, i = self._find(index) + if index == i: + self._delete(prev, node) + else: + print('Node with index {} not found'.format(index)) + + + +if __name__ == '__main__': + ll = LinkedList() + for i in range(1, 5): + ll._add(i) + + print('The list is:') + ll._printList() + + print('The list after deleting node with index 2:') + ll.deleteNode(2) + ll._printList() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/longest_common_prefix.py b/MY_BOOK/ebook_src/real_interview_problems/longest_common_prefix.py new file mode 100644 index 0000000..c339ad3 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/longest_common_prefix.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def longest_common_substring(s1, s2): + p1 = 0 + aux, lcp = '', '' + string1 = max(s1, s2) + string2 = min(s1, s2) + + while p1 < len(string1): + p2 = 0 + while p2 < len(string2) and p1+p2 < len(string1): + if string1[p1+p2] == string2[p2]: + aux += string1[p1+p2] + else: + if len(lcp) < len(aux): + lcp = aux + aux = '' + p2 += 1 + p1 += 1 + + return lcp + + + +if __name__ == '__main__': + str1 = 'hasfgeaae' + str2 = 'bafgekk' + result = 'fge' + assert(longest_common_substring(str1, str2) == result) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/longest_increasing_subsequence.py b/MY_BOOK/ebook_src/real_interview_problems/longest_increasing_subsequence.py new file mode 100644 index 0000000..ca1c2e9 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/longest_increasing_subsequence.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def longest_increasing_subsequence(seq): + result, aux = [], [] + seq.append(-float('infinity')) + + for i, value in enumerate(seq[:-1]): + aux.append(value) + if value > seq[i+1]: + if len(result) < len(aux): + result = aux[:] + aux = [] + return result + + + +if __name__ == '__main__': + seq = [10, -12, 2, 3, -3, 5, -1, 2, -10] + result = [-12, 2, 3] + assert(longest_increasing_subsequence(seq) == result) + + seq = [2] + result = [2] + assert(longest_increasing_subsequence(seq) == result) + + seq = [] + result = [] + assert(longest_increasing_subsequence(seq) == result) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/merge_sort.py b/MY_BOOK/ebook_src/real_interview_problems/merge_sort.py new file mode 100644 index 0000000..40c3691 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/merge_sort.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# AKA: do you believe in magic? + +__author__ = "bt3" + +def merge_sort(array): + if len(array) < 2: + return array + + # divide + mid = len(array)//2 + left = merge_sort(array[:mid]) + right = merge_sort(array[mid:]) + + # merge + result = [] + i, j = 0, 0 + + while i < len(left) and j < len(right): + if left[i] < right[j]: + result.append(left[i]) + i += 1 + else: + result.append(right[j]) + j+= 1 + + # make sure nothing is left behind + if left[i:]: + result.extend(left[i:]) + if right[j:]: + result.extend(right[j:]) + + return result + + + + +if __name__ == '__main__': + array = [3, 1, 6, 0, 7, 19, 7, 2, 22] + sorted = [0, 1, 2, 3, 6, 7, 7, 19, 22] + assert(merge_sort(array) == sorted) + + array = [] + assert(merge_sort(array) == array) + + array = [1] + assert(merge_sort(array) == array) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/PYTHON.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/PYTHON.md new file mode 100644 index 0000000..bb4c5af --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/PYTHON.md @@ -0,0 +1,281 @@ + +## Python General Questions & Answers + +Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source. + + +#### What is PEP 8? + +PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable. + + +#### What is pickling and unpickling? + +Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using a dump function, this process is called pickling. While the process of retrieving original Python objects from the stored string representation is called unpickling. + + +#### How Python is interpreted? + +Python language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed. + + +#### How memory is managed in Python? + +Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have access to this private heap and interpreter takes care of this Python private heap. +The allocation of Python heap space for Python objects is done by Python memory manager. The core API gives access to some tools for the programmer to code. +Python also has an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space. + + +#### What are the tools that help to find bugs or perform static analysis? + +PyChecker is a static analysis tool that detects the bugs in Python source code and warns about the style and complexity of the bug. Pylint is another tool that verifies whether the module meets the coding standard. + + +#### What are Python decorators? + +A Python decorator is a specific change that we make in Python syntax to alter functions easily. + +#### What is the difference between list and tuple? + +The difference between list and tuple is that list is mutable while tuple is not. Tuple can be hashed for e.g as a key for dictionaries. + + +#### How are arguments passed by value or by reference? + +Everything in Python is an object and all variables hold references to the objects. The references values are according to the functions; as a result, you cannot change the value of the references. However, you can change the objects if it is mutable. + + + +#### What are the built-in type does python provides? + +There are mutable and Immutable types of Pythons built-in types Mutable built-in types + +List +Sets +Dictionaries +Immutable built-in types +Strings +Tuples +Numbers + + +#### What is namespace in Python? + +In Python, every name introduced has a place where it lives and can be hooked for. This is known as namespace. It is like a box where a variable name is mapped to the object placed. Whenever the variable is searched out, this box will be searched, to get the corresponding object. + + +#### What is lambda in Python? + +It is a single expression anonymous function often used as an inline function. + + +#### Why lambda forms in python do not have statements? + +A lambda form in python does not have statements as it is used to make new function object and then return them at runtime. + + +#### What is pass in Python? + +Pass means, no-operation Python statement, or in other words, it is a place holder in a compound statement, where there should be a blank left and nothing has to be written there. + + + +#### In Python what are iterators? + +In Python, iterators are used to iterate a group of elements, containers like list. + + +#### What is unittest in Python? + +A unit testing framework in Python is known as unittest. It supports sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections, etc. + + +#### In Python what is slicing? + +A mechanism to select a range of items from sequence types like list, tuple, strings, etc. is known as slicing. + + +#### What are generators in Python? + +The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function. + + +#### What is docstring in Python? + +A Python documentation string is known as docstring, it is a way of documenting Python functions, modules and classes. + + +#### How can you copy an object in Python? + +To copy an object in Python, you can try copy.copy () or copy.deepcopy() for the general case. You cannot copy all objects but most of them. + +#### What is the difference between deep and shallow copy? + +Shallow copy is used when a new instance type gets created and it keeps the values that are copied in the new instance. Whereas, a deep copy is used to store the values that are already copied. + +#### What is a negative index in Python? + +Python sequences can be index in positive and negative numbers. For positive index, 0 is the first index, 1 is the second index and so forth. For negative index, (-1) is the last index and (-2) is the second last index and so forth. + + +#### How you can convert a number to a string? + +In order to convert a number into a string, use the inbuilt function str(). If you want a octal or hexadecimal representation, use the inbuilt function oct() or hex(). + + +#### What is the difference between Xrange and range? + +Xrange returns the xrange object while range returns the list, and uses the same memory no matter what the range size is. + + +#### What is module and package in Python? + +In Python, a module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes. +The folder of Python program is a package of modules. A package can have modules or subfolders. + + +#### What are the rules for local and global variables in Python? + +Local variables: If a variable is assigned a new value anywhere within the function's body, it's assumed to be local. + +Global variables: Those variables that are only referenced inside a function are implicitly global. + + +#### How can you share global variables across modules? + +To share global variables across modules within a single program, create a special module. Import the config module in all modules of your application. The module will be available as a global variable across modules. + + +#### Explain how can you make a Python Script executable on Unix? + +To make a Python Script executable on Unix, you need to do two things, + +Script file's mode must be executable and +the first line must begin with # (`#!/usr/local/bin/python`). + + +#### Explain how to delete a file in Python? + +By using a command `os.remove (filename)` or `os.unlink(filename)`. + + +#### Explain how can you generate random numbers in Python? + +To generate random numbers in Python, you need to import command as + +``` +import random +random.random() +``` + +This returns a random floating point number in the range [0,1) + + +#### Explain how can you access a module written in Python from C? + +You can access a module written in Python from C by following method, + +``` +Module = =PyImport_ImportModule(""); +``` + + +#### Mention the use of // operator in Python? + +It is a Floor Division operator, which is used for dividing two operands with the result as quotient showing only digits before the decimal point. For instance, `10//5 = 2 and 10.0//5.0 = 2.0`. + + +#### Explain what is Flask & its benefits? + +Flask is a web microframework for Python based on "Werkzeug, Jinja 2 and good intentions" BSD licensed. Werkzeug and jingja are two of its dependencies. + +Flask is part of the micro-framework. Which means it will have little to no dependencies on external libraries. It makes the framework light while there is a little dependency to update and fewer security bugs. + + +#### What is the difference between Django, Pyramid, and Flask? + +Flask is a "microframework" primarily build for a small application with simpler requirements. In Flask, you have to use external libraries. Flask is ready to use. + +Pyramid is built for larger applications. It provides flexibility and lets the developer use the right tools for their project. The developer can choose the database, URL structure, templating style and more. Pyramid is heavy configurable. + +Like Pyramid, Django can also be used for larger applications. It includes an ORM. + + +#### Explain how you can access sessions in Flask? + +A session basically allows you to remember information from one request to another. In a flask, it uses a signed cookie so the user can look at the session contents and modify. The user can modify the session if only it has the secret key Flask.secret_key. + + +#### Is Flask an MVC model and if yes give an example showing MVC pattern for your application? + +Basically, Flask is a minimalistic framework which behaves the same as MVC framework. So MVC is a perfect fit for Flask, and the pattern for MVC we will consider for the following example: + +```python +from flask import Flask + +app = Flask(_name_) + +@app.route("/") + +Def hello(): + +return "Hello World" + +app.run(debug = True) +``` + +#### Explain database connection in Python Flask? + +Flask supports database powered application (RDBS). Such a system requires creating a schema, which requires piping the shema.sql file into a sqlite3 command. So you need to install sqlite3 command in order to create or initiate the database in Flask. + +Flask allows requesting database in three ways + +* before_request() : They are called before a request and pass no arguments. +* after_request() : They are called after a request and pass the response that will be sent to the client. +* teardown_request(): They are called in a situation when an exception is raised, and response is not guaranteed. They are called after the response been constructed. They are not allowed to modify the request, and their values are ignored. + + + +#### You are having multiple Memcache servers running Python, in which one of the Memcache server fails, and it has your data, will it ever try to get key data from that one failed server? + +The data in the failed server won't get removed, but there is a provision for auto-failure, which you can configure for multiple nodes. Fail-over can be triggered during any kind of socket or Memcached server level errors and not during normal client errors like adding an existing key, etc. + + +#### Explain how you can minimize the Memcached server outages in your Python Development? + +When one instance fails, several of them goes down, this will put a larger load on the database server when lost data is reloaded as the client make a request. To avoid this, if your code has been written to minimize cache stampedes then it will leave a minimal impact. + +Another way is to bring up an instance of Memcached on a new machine using the lost machines IP address. + + +#### Explain how Memcached should not be used in your Python project? + +Memcached common misuse is to use it as a data store, and not as a cache. Never use Memcached as the only source of the information you need to run your application. Data should always be available through another source as well. Memcached is just a key or value store and cannot perform query over the data or iterate over the contents to extract information. Memcached does not offer any form of security either in encryption or authentication. + +#### What's a metaclass in Python? + +This type of class holds the instructions about the behind-the-scenes code generation that you want to take place when another piece of code is being executed. With a metaclass, we can define properties that should be added to new classes that are defined in our code. + +#### Why isn't all memory freed when Python exits? +Objects referenced from the global namespaces of Python modules are not always deallocated when Python exits. This may happen if there are circular references. There are also certain bits of memory that are allocated by the C library that are impossible to free/ Python is, however, aggressive about cleaning up memory on exit and does try to destroy every single object. + +If you want to force Python to delete certain things on deallocation, you can use the atexit module to register one or more exit functions to handle those deletions. + +#### Usage of `__slots__`? + +The special attribute `__slots__` allows you to explicitly state which instance attributes you expect your object instances to have, with the expected results: + +* faster attribute access. +* space savings in memory. + +#### What id() function in Python is for? + +`id()` function accepts a single parameter and is used to return the identity of an object. This identity has to be unique and constant for this object during the lifetime. Two objects with non-overlapping lifetimes may have the same `id()` value. + +#### Is Python call-by-value or call-by-reference? + +Neither. In Python, (almost) everything is an object. What we commonly refer to as "variables" in Python are more properly called names. Likewise, "assignment" is really the binding of a name to an object. Each binding has a scope that defines its visibility, usually the block in which the name originates. + +In Python a variable is not an alias for a location in memory. Rather, it is simply binding to a Python object.ext post. + +---- diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/.gitignore b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/.gitignore new file mode 100644 index 0000000..cb7d5e7 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/.gitignore @@ -0,0 +1,44 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/001-multiples_of_3_and_5.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/001-multiples_of_3_and_5.py new file mode 100644 index 0000000..f63adf8 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/001-multiples_of_3_and_5.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + +def mul3and5(n): + result = 0 + for num in range(1, n): + if num%3 == 0 or num%5 == 0: + result += num + return result + + + +def test_(): + assert(mul3and5(10) == 23) + print(mul3and5(1000)) + print('Tests Passed!') + +if __name__ == '__main__': + test_() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/002-even_fib_num.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/002-even_fib_num.py new file mode 100644 index 0000000..f465b29 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/002-even_fib_num.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + +def even_fib_num(limit): + a, b = 0, 1 + while a < limit: + yield a + a, b = b, a + b + +def main(): + print(sum(n for n in even_fib_num(4e6) if not (n & 1))) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/003-largest_prime_factor.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/003-largest_prime_factor.py new file mode 100644 index 0000000..0c8eb6b --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/003-largest_prime_factor.py @@ -0,0 +1,41 @@ +#!/usr/bin/python3 +#!/usr/bin/python3 + +def is_prime(n): + if n < 4 : return True + for i in range(2, int(n**0.5 + 1)): + if not n%i: return False + return True + + +def largest_prime_factor(n): + i = int(n**0.5 +1) + while i > 1 : + if not n%i and i&1: + if is_prime(i): return i + i -= 1 + return None + + +def largest_prime_factor_optimized(n): + factor = 2 + lastfactor = 1 + while n > 1: + if not n%factor: + lastfactor = factor + n = n//factor + while n%factor == 0: + n = n//factor + factor += 1 + return lastfactor + + +def test_largest_prime_factor(): + assert(largest_prime_factor(13195)== 29) + print(largest_prime_factor(600851475143)) + assert(largest_prime_factor_optimized(13195) == 29) + print(largest_prime_factor_optimized(600851475143)) + print('Tests Passed!') + +if __name__ == '__main__': + test_largest_prime_factor() diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/004-larg_palindrome.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/004-larg_palindrome.py new file mode 100644 index 0000000..e9f6a89 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/004-larg_palindrome.py @@ -0,0 +1,47 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + + +def is_palindrome(s): + return s == reverse(s) + +def reverse(s): + rev = 0 + while s > 0: + rev = 10*rev + s%10 + s = s//10 + return rev + + +def is_palindrome_2(s): + # to use it you need to cast str() first + while s: + if s[0] != s[-1]: return False + else: + s = s[1:-1] + is_palindrome(s) + return True + + +def larg_palind_product(n): + nmax, largpal = 9, 0 + for i in range(1, n): + nmax += 9*10**i + for i in range(nmax, nmax//2, -1): + for j in range(i -1, (i -1)//2, -1): + candidate = i*j + if is_palindrome(candidate) and candidate > largpal: + largpal = candidate + return largpal + + +def test_larg_palind_product(): + assert(larg_palind_product(2)== 9009) + print(larg_palind_product(3)) + print('Tests Passed!') + +if __name__ == '__main__': + test_larg_palind_product() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/005-smallest_multiple.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/005-smallest_multiple.py new file mode 100644 index 0000000..23d3e4e --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/005-smallest_multiple.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 + +def smallest_multiple(n): + set1 = set([x for x in range(1, n+1)]) + set2 = set() + for i in range(len(set1), 0, -1): + for j in range(1, i): + if i%j == 0: + set2.add(j) + set1 = set1 - set2 + res_num = n*n + while True: + for i in set1: + missing_div = False + if res_num%i: + missing_div = True + shift = res_num%i + break + if not missing_div: return res_num + res_num += 1 or shift + shift = 0 + + + + +def test_(): + assert(smallest_multiple(10) == 2520) + print(smallest_multiple(20)) + print('Tests Passed!') + +if __name__ == '__main__': + test_() diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/006-sum_square_diff.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/006-sum_square_diff.py new file mode 100644 index 0000000..8cbc368 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/006-sum_square_diff.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + +def sum_square_diff(n): + sq_sum, sum_sq = 0, 0 + for i in range(1, n+1): + sum_sq += i**2 + sq_sum += i + sq_sum = sq_sum **2 + return sq_sum - sum_sq + +def main(): + assert(sum_square_diff(10) == 2640) + print(sum_square_diff(100)) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/007-findstprime.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/007-findstprime.py new file mode 100644 index 0000000..4f56209 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/007-findstprime.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +import math + +def is_prime(number, prime_set): + if number in prime_set: return True + for i in range(2, int(math.sqrt(number)) + 1): + if not number%i: return False + return True + + +def findstprime(n): + count = 0 + candidate = 1 + prime_set = set() + while count < n: + candidate +=1 + if is_prime(candidate, prime_set): + prime_set.add(candidate) + count += 1 + return candidate + +def main(): + assert(findstprime(6 == 13)) + print(findstprime(10001)) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/008-largest_product_seq.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/008-largest_product_seq.py new file mode 100644 index 0000000..65fefa2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/008-largest_product_seq.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + + +def largest_prod_seq(n): + result = 0 + for i in range(0, len(n)-4): + first = int(n[i]) + second = int(n[i+1]) + third = int(n[i+2]) + fourth = int(n[i+3]) + fifth = int(n[i+4]) + result_here = first*second*third*fourth*fifth + if result < result_here: + result = result_here + return result + + +def main(): + n = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450' + print(largest_prod_seq(n)) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/009-special_pyt.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/009-special_pyt.py new file mode 100644 index 0000000..2fa2dde --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/009-special_pyt.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + + +def special_pyt(n): + for i in range(3, n): + for j in range(i+1, n): + c = calc_c(i,j) + if i + j + c == n: + return i*j*c + +def calc_c(a, b): + return (a**2 + b**2)**0.5 + + + +def main(): + assert(special_pyt(3+4+5) == (3*4*5)) + print(special_pyt(1000)) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/010-summation_primes.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/010-summation_primes.py new file mode 100644 index 0000000..fb53b56 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/010-summation_primes.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +from findstprime import is_prime + +def summation_primes(n): + candidate = 2 + prime_set = set() + while candidate < n: + if is_prime(candidate, prime_set): + prime_set.add(candidate) + candidate +=1 + return sum(prime_set) + + +def main(): + assert(summation_primes(10) == 17) + print(summation_primes(2000000)) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/011-larg_prod_grid.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/011-larg_prod_grid.py new file mode 100644 index 0000000..4af10c5 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/011-larg_prod_grid.py @@ -0,0 +1,66 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +import string + +def get_grid(filename): + grid = [ [ 0 for i in range(20) ] for j in range(20) ] + with open(filename) as file: + for row, line in enumerate(file): + line.strip('\n') + for collumn, number in enumerate(line.split(' ')): + grid[row][collumn] = int(number) + return grid + + +def larg_prod_grid(grid): + row, col, larg_prod = 0, 0, 0 + up, down, left, right, diag1, diag2, diag3, diag4 = 0, 0, 0, 0, 0, 0, 0, 0 + while row < len(grid): + while col < len(grid[0]): + if col > 2: + up = grid[row][col] * grid[row][col-1] * grid[row][col-2] * grid[row][col-3] + if col < len(grid[0]) - 3: + down = grid[row][col] * grid[row][col+1] * grid[row][col+2] * grid[row][col+3] + if row > 2: + left = grid[row][col] * grid[row-1][col] * grid[row-2][col] * grid[row-3][col] + if row < len(grid) - 3: + right = grid[row][col] * grid[row+1][col] * grid[row+2][col] * grid[row+3][col] + + if col > 2 and row > 2: + diag1 = grid[row][col] * grid[row-1][col-1] * grid[row-2][col-2] * grid[row-3][col-3] + if col > 2 and row < len(grid) - 3: + diag2 = grid[row][col] * grid[row+1][col-1] * grid[row+2][col-2] * grid[row+3][col-3] + + if col < len(grid[0]) - 3 and row > 2: + diag3 = grid[row][col] * grid[row-1][col+1] * grid[row-2][col+2] * grid[row-3][col+3] + if col < len(grid[0]) -3 and row < len(grid) - 3: + down = grid[row][col] * grid[row+1][col+1] * grid[row+1][col+2] * grid[row+1][col+3] + + l1 = [up, down, left, right, diag1, diag2, diag3, diag4] + largest_prod_here = max(l1) + if largest_prod_here > larg_prod: + larg_prod = largest_prod_here + col += 1 + col = 0 + row += 1 + + return larg_prod + + +def main(): + import time + start = time.time() + + filename = 'larg_prod_grid.dat' + grid = get_grid(filename) + assert((grid[6][8], grid[7][9], grid[8][10], grid[9][11]) == (26, 63, 78, 14)) + print(larg_prod_grid(grid)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/012-highly_divisible_trian_num.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/012-highly_divisible_trian_num.py new file mode 100644 index 0000000..41cd2f1 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/012-highly_divisible_trian_num.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +import math + +def find_div(n): + ''' find the divisor of a given n''' + set_div = {1, n} + for i in range(2, int(math.sqrt(n))+ 1): + if not n % i: + set_div.add(i) + set_div.add(n//i) + l1 = list(set_div) + return len(l1) + + +def find_trian(l): + ''' find the lth trian number''' + return sum(range(1, l+1)) + + +def highly_divisible_trian_num(d): + thtriangle, n_div, count = 1, 0, 1 + while n_div < d: + count += 1 + thtriangle += count + n_div = find_div(thtriangle) + return (thtriangle, count) + + +def main(): + import time + start = time.time() + assert(highly_divisible_trian_num(6) == (28, 7)) + print(highly_divisible_trian_num(500)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/013-large_sum.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/013-large_sum.py new file mode 100644 index 0000000..4d0ac69 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/013-large_sum.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def large_sum(filename): + sum_total, lines, numbers = 0, 0, 0 + with open(filename) as file: + for line in file: + sum_total += int(line.strip('\n')) + return str(sum_total)[0:10] + + +def main(): + import time + start = time.time() + + filename = 'large_sum.dat' + print(large_sum(filename)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/014-long_collatz_seq.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/014-long_collatz_seq.py new file mode 100644 index 0000000..70535e2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/014-long_collatz_seq.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def find_coll_seq(n): + count = 1 + while n > 1: + if n%2 == 0: + n = n//2 + else: + n = 3*n +1 + count += 1 + return count + + +def find_longest_chain(limit): + longest, number = 0, 0 + start = 0 + while start <= limit: + size_chain = find_coll_seq(start) + if size_chain > longest: + longest = size_chain + number = start + start += 1 + + return (longest, number) + + + + +def main(): + import time + start = time.time() + + #print(find_longest_chain(13)) + print(find_longest_chain(10**6)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/015-lattice_paths.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/015-lattice_paths.py new file mode 100644 index 0000000..8c4fb20 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/015-lattice_paths.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def lattice_paths(squares): + gridsize = squares+1 + grid = [[0 for i in range(gridsize)] for j in range(gridsize)] + row, col = 0, 0 + + while col < gridsize: + while row < gridsize: + + if row == 0 and col == 0: + grid[row][col] = 1 + + else: + if row == 0 and col != 0: + grid[row][col] += grid[row][col-1] + elif row != 0 and col == 0: + grid[row][col] += grid[row-1][col] + else: + grid[row][col] += grid[row][col-1] + grid[row-1][col] + + row += 1 + row = 0 + col += 1 + return grid[gridsize-1][gridsize-1] + + +def main(): + import time + start = time.time() + + assert(lattice_paths(2) == 6) + print(lattice_paths(20)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/016-power_digit_sum.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/016-power_digit_sum.py new file mode 100644 index 0000000..a47d1db --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/016-power_digit_sum.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + +def power_digit_sum(n): + number = str(2**n) + sum_res = 0 + for i in number: + sum_res += int(i) + return sum_res + + + +def test_(): + assert(power_digit_sum(15) == 26) + print(power_digit_sum(1000)) + print('Tests Passed!') + +if __name__ == '__main__': + test_() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/017-number_letter_counts.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/017-number_letter_counts.py new file mode 100644 index 0000000..8b1b43b --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/017-number_letter_counts.py @@ -0,0 +1,63 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + + +def number_letter_counts(n): + dict_lett = build_dict(n) + sum_letter = 0 + for item in dict_lett: + sum_letter += dict_lett[item] + return sum_letter + + +def build_dict(n): + lett_dict = {} + numbers = (x for x in range(1, n+1)) + dec = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] + ties = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] + + for number in numbers: + if 1 <= number < 20: + lett_dict[number] = len(dec[number-1]) + elif 20 <= number < 100: + index_dec = number//10 + index_num = number%10 + if index_num == 0: + lett_dict[number] = len(ties[index_dec-2]) + else: + lett_dict[number] = len(ties[index_dec-2]) + len(dec[index_num-1]) + elif 100 <= number < 1000: + index_hun = number//100 + index_dec = number%100 + if index_dec == 0: + lett_dict[number] = len(dec[index_hun-1]) + len('hundred') + else: + if 1 <= index_dec < 20: + lett_dict[number] = len(dec[index_hun-1]) + len('hundred') + len('and') + len(dec[index_dec-1]) + elif 20 <= index_dec < 100: + index_dec2 = index_dec//10 + index_num = index_dec%10 + if index_num == 0: + lett_dict[number] = len(dec[index_hun-1]) + len('hundred') + len('and') + len(ties[index_dec2-2]) + else: + lett_dict[number] = len(dec[index_hun-1]) + len('hundred') + len('and') + len(ties[index_dec2-2]) + len(dec[index_num-1]) + elif number == 1000: + lett_dict[number] = len('onethousand') + + return lett_dict + + +def main(): + import time + start = time.time() + + assert(number_letter_counts(5) == 19) + print(number_letter_counts(1000)) + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/018-max_path_sum.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/018-max_path_sum.py new file mode 100644 index 0000000..955a40f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/018-max_path_sum.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def max_path_sum(t): + root = t[0][0] + height, width, index, large_num = 1, 0, 0, 0 + max_sum = root + heights = len(t[:]) + + while height < heights: + values_here = t[height][index:index+2] + if values_here[0] > values_here[1]: + large_num = values_here[0] + else: + large_num = values_here[1] + index += 1 + max_sum += large_num + pivot = large_num + width, large_num = 0, 0 + height += 1 + + return max_sum + +def edit_input(filename): + output = [] + with open(filename) as file: + for line in file: + line = line.rstrip('\n') + output.append(line.split(' ')) + for i, l1 in enumerate(output): + for j, c in enumerate(output[i]): + output[i][j] = int(c) + return(output) + + + +def main(): + import time + start = time.time() + + filename = 'max_path_sum0.dat' + t1 = edit_input(filename) + print('Little pir: ',max_path_sum(t1)) + + filename = 'max_path_sum.dat' + t2 = edit_input(filename) + print('Big pir: ', max_path_sum(t2)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/019-counting_sundays.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/019-counting_sundays.py new file mode 100644 index 0000000..6951b8f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/019-counting_sundays.py @@ -0,0 +1,65 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +''' +1 Jan 1900 was a Monday. +Thirty days has September, +April, June and November. +All the rest have thirty-one, +Saving February alone, +Which has twenty-eight, rain or shine. +And on leap years, twenty-nine. +A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. +How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? +''' + + +def find_if_leap_year(y): + if (y%4 == 0 and y%100 != 0) or (y%400 == 0): + return True + return False + + +def counting_sundays(): + ''' define variables ''' + days_year = 7*31 + 4*30 + 28 + count_sundays = 0 + days_week = 7 + dict_week = {0: 'mon', 1:'tue', 2:'wed', 3:'thu', 4:'fri', 5:'sat', 6:'sun'} + + + ''' with info from 1900 find first day for 1901 ''' + first_day = days_year%days_week # not a leap year + + for y in range (1901, 2001): + leap_year = find_if_leap_year(y) + days_count = first_day + + for m in range(1, 13): + if days_count%7 == 6: + count_sundays += 1 + if m == 2: + if leap_year: + days_count += 29 + else: + days_count += 28 + elif m == 4 or m == 6 or m == 9 or m == 11: + days_count += 30 + else: + days_count += 31 + + if leap_year: first_day = (first_day +2)%days_week + else: first_day = (first_day +1)%days_week + + return count_sundays + + + +def main(): + print(counting_sundays()) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/020-factorial.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/020-factorial.py new file mode 100644 index 0000000..b19bea2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/020-factorial.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def factorial(n): + prod = 1 + for i in range(1,n): + prod *= i + return prod + +def find_sum(n): + sum_ = 0 + fact = factorial(n) + number = str(fact) + for i in number: + sum_ += int(i) + return sum_ + + +def main(): + import time + start = time.time() + + assert(find_sum(10) == 27) + print(find_sum(100)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/021-amicable_numbers.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/021-amicable_numbers.py new file mode 100644 index 0000000..02c262b --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/021-amicable_numbers.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +''' +Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). +If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a and b are called amicable numbers. + +For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. + +Evaluate the sum of all the amicable numbers under 10000. +''' + +def find_sum_proper_divisors(n): + sum_proper_div = 0 + for i in range(1, n): + if n%i == 0: + sum_proper_div += i + return sum_proper_div + + +def amicable_numbers(N): + sum_div_list = [find_sum_proper_divisors(i) for i in range(1, N+1)] + sum_amicable_numbers = 0 + set_div = set() + for a in range(1, N): + da = sum_div_list[a-1] + if da < N: + b = da + db = sum_div_list[b-1] + if a != b and db == a and a not in set_div and b not in set_div: + sum_amicable_numbers += a + b + set_div.add(a) + set_div.add(b) + return sum_amicable_numbers + + +def main(): + print(amicable_numbers(10000)) + print('Tests Passed!') + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/022-names_score.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/022-names_score.py new file mode 100644 index 0000000..7c2f1bb --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/022-names_score.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + +def calculate_score(name, dict_letters): + sum_letters = 0 + for letter in name: + sum_letters += dict_letters[letter] + return sum_letters + +def names_score(filename): + dict_letters ={'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'H':8,'I':9,'J':10,'K':11,'L':12,'M':13,'N':14,'O':15,'P':16,'Q':17,'R':18,'S':19, 'T':20,'U':21,'V':22,'W':23,'X':24,'Y':25,'Z':26} + total_score = 0 + with open(filename) as file: + for line in file: + names = [name.strip('"') for name in line.split(',')] + names.sort() + for i, name in enumerate(names): + total_score += (i+1)* calculate_score(name, dict_letters) + + return total_score + + + +def main(): + filename = 'names.txt' + print(names_score(filename)) + + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/023-non_abund_sums.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/023-non_abund_sums.py new file mode 100644 index 0000000..2f9e496 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/023-non_abund_sums.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def find_sum_proper_div(n): + sum_proper_div = 0 + for i in range(1, n): + if n%i == 0: + sum_proper_div += i + return sum_proper_div + + +def find_all_abund(n): + sum_div_list = [find_sum_proper_div(i) for i in range(n)] + abu = set() + for i in range(n): + if i < sum_div_list[i]: + abu.add(i) + return abu + + +def non_abund_sums(n): + abu = find_all_abund(n) + sum_nom_abu = 0 + + for i in range(n): + if not any( (i-a in abu) for a in abu): + sum_nom_abu += i + + return sum_nom_abu + + +def test_(): + r = set([i for i in range(25)]) + r_abu = {24} + r = r - r_abu + assert(non_abund_sums(25) == sum(r)) + print(non_abund_sums(28123)) + print('Tests Passed!') + + +if __name__ == '__main__': + test_() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/024-lexico_per.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/024-lexico_per.py new file mode 100644 index 0000000..52a5ccb --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/024-lexico_per.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def perm_item(elements): + if len(elements) <= 1: + yield elements + else: + for (index, elmt) in enumerate(elements): + other_elmts = elements[:index]+elements[index+1:] + for permutation in perm_item(other_elmts): + yield [elmt] + permutation + + +def lex_perm(l1, n): + perm_list = list(perm_item(l1)) + return sorted(perm_list)[n-1] + + +def main(): + import time + start = time.time() + + l1 = [0,1,2,3,4,5,6,7,8,9] + n = 10**6 + print(lex_perm(l1, n)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/025-100-digit-fib.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/025-100-digit-fib.py new file mode 100644 index 0000000..142de97 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/025-100-digit-fib.py @@ -0,0 +1,63 @@ +#!/usr/bin/python3 +# mari wahl @2014 +# marina.w4hl at gmail +# + +''' +The Fibonacci sequence is defined by the recurrence relation: + Fn = Fnāˆ’1 + Fnāˆ’2, where F1 = 1 and F2 = 1. + Hence the first 12 terms will be: + +F1 = 1 +F2 = 1 +F3 = 2 +F4 = 3 +F5 = 5 +F6 = 8 +F7 = 13 +F8 = 21 +F9 = 34 +F10 = 55 +F11 = 89 +F12 = 144 +The 12th term, F12, is the first term to contain three digits. + +What is the first term in the Fibonacci sequence to contain 1000 digits? +Answer: 4782 +''' + + +def fib(num=1, num_before=1): + found = False + + num_before, num = num, num + num_before + + if count_digits(num) == 1000: found = True + + return num, num_before, found + + + +def count_digits(num): + num_str = str(num) + return len(num_str) + + + +def main(): + found = False + num = 1 + num_before = 1 + count = 2 + + while not found: + num, num_before, found = fib(num, num_before) + count +=1 + + print(count) + print('Done!') + +if __name__ == '__main__': + main() + + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/026-reciprocal-cycles.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/026-reciprocal-cycles.py new file mode 100644 index 0000000..28f6f61 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/026-reciprocal-cycles.py @@ -0,0 +1,40 @@ +#!/usr/bin/python3 +# mari wahl @2014 +# marina.w4hl at gmail + + +''' +A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: + +1/2 = 0.5 +1/3 = 0.(3) +1/4 = 0.25 +1/5 = 0.2 +1/6 = 0.1(6) +1/7 = 0.(142857) +1/8 = 0.125 +1/9 = 0.(1) +1/10 = 0.1 +Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle. + +Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part. + +Answer: 983 +''' + + +def recurring_cycle(n, d): + for dd in range(1, d): + if 1 == 10**dd % d: + return dd + return 0 + +def main(): + n = 1 + limit = 1000 + longest = max(recurring_cycle(n, i) for i in range(2, limit+1)) + print [i for i in range(2, limit+1) if recurring_cycle(n, i) == longest][0] + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/027-quad_primes.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/027-quad_primes.py new file mode 100644 index 0000000..af84e3f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/027-quad_primes.py @@ -0,0 +1,50 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def quad_form(n, a, b): + return n**2 + a*n + b + +def isPrime(n): + n = abs(int(n)) + if n < 2: + return False + if n == 2: + return True + if not n & 1: + return False + for x in range(3, int(n**0.5)+1, 2): + if n % x == 0: + return False + return True + +def quad_primes(a, b): + count_max = 0 + coef = () + for aa in range(-a, a): + for bb in range(-b, b): + n = 0 + while True: + number = quad_form(n, aa, bb) + if isPrime(number): + n += 1 + else: + if n > count_max: + count_max = n + coef = (aa, bb) + break + return coef(0)*coef(1), coef + + +def main(): + import time + start = time.time() + + print(quad_primes(1000, 1000)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/028-number_spiral.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/028-number_spiral.py new file mode 100644 index 0000000..387146d --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/028-number_spiral.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def number_spiral(spiral): + + + return rows, mid + +def make_spiral(n): + spiral = [] + row = rows//2 + col = col//2 + count = 1 + while row < n: + while col < n: + spiral[col][row] = count + count += 1 + if count%2 == 0: + col += 1 + else: + row += 1 + + return spiral + +def main(): + import time + start = time.time() + + n = 5 + spiral = make_spiral(n) + print(number_spiral(spiral))# 101 + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/029-dist_pow.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/029-dist_pow.py new file mode 100644 index 0000000..0b47350 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/029-dist_pow.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def dist_pow(a1, a2, b1, b2): + set1 = set() + for a in range(a1, a2 + 1): + for b in range(b1, b2 + 1): + set1.add(a**b) + return len(set1) + + + + +def main(): + import time + start = time.time() + + print(dist_pow(2, 5, 2, 5)) + print(dist_pow(2, 100, 2, 100)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/030-digit_fifth_pow.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/030-digit_fifth_pow.py new file mode 100644 index 0000000..14a9985 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/030-digit_fifth_pow.py @@ -0,0 +1,30 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def digit_fifth_pow(n): + lnum = [] + for num in range(10**(2), 10**(n+2)): + sum_here = 0 + num_str = str(num) + for i in num_str: + num_int = int(i) + num_int_pow = num_int**n + sum_here += num_int_pow + if sum_here == num: + lnum.append(num) + return lnum, sum(lnum) + + +def main(): + import time + start = time.time() + + print(digit_fifth_pow(5)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/031-coin_sums.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/031-coin_sums.py new file mode 100644 index 0000000..d6e6d7e --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/031-coin_sums.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +# mari wahl @2014 +# marina.w4hl at gmail +''' +In England the currency is made up of pound, Ā£, and pence, p, and there are eight coins in general circulation: + +1p, 2p, 5p, 10p, 20p, 50p, Ā£1 (100p) and Ā£2 (200p). +It is possible to make Ā£2 in the following way: + +1Ć—Ā£1 + 1Ɨ50p + 2Ɨ20p + 1Ɨ5p + 1Ɨ2p + 3Ɨ1p +How many different ways can Ā£2 be made using any number of coins? +''' + + + + +def main(): + import time + start = time.time() + + print(digit_fifth_pow(5)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/032-pandigital.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/032-pandigital.py new file mode 100644 index 0000000..1d08348 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/032-pandigital.py @@ -0,0 +1,51 @@ +#!/usr/bin/python + + +__author__ = "Mari Wahl" +__email__ = "marina.w4hl@gmail.com" + +''' +We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. +The product 7254 is unusual, as the identity, 39 x 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. +Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital. +''' + + + +def isPandigitalString(string): + """ Check if string contains a pandigital number. """ + digits = len(string) + + if digits >= 10: + return False + + for i in range(1,digits+1): + if str(i) not in string: + return False + return True + + + +def gives9PandigitalProduct(a, b): + numbers = str(a) + str(b) + str(a*b) + if len(numbers) != 9: + return False + return isPandigitalString(numbers) + + +def main(): + products = [] + + for a in range(0, 100000): + for b in range(a, 100000): + if len(str(a*b) + str(a) + str(b)) > 9: + break + if gives9PandigitalProduct(a, b): + products.append(a*b) + print("%i x %i = %i" % (a, b, a*b)) + + print(sum(set(products))) + + +if __name__ == '__main__': + main() diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/035-circular_primes.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/035-circular_primes.py new file mode 100644 index 0000000..1f89d6f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/035-circular_primes.py @@ -0,0 +1,91 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def isPrime(n): + n = abs(int(n)) + if n < 2: + return False + if n == 2: + return True + for x in range(2, int(n**0.5)+1): + if n%x == 0: + return False + return True + + +def findPermutations(s): + res = [] + if len(s) == 1: + res.append(s) + else: + for i, c in enumerate(s): + for perm in findPermutations(s[:i] + s[i+1:]): + res.append(c + perm) + return res + + + + + +def isCircular(n): + n_str = str(n) + permutations = findPermutations(n_str) + for perm in permutations: + if not isPrime(perm): + return False + return True + + + +def generatePrimes(n): + if n == 2: return [2] + elif n < 2: return [] + s = [i for i in range(3, n+1, 2)] + mroot = n ** 0.5 + half = (n+1)//2 - 1 + i, m = 0, 3 + while m <= mroot: + if s[i]: + j = (m*m-3)//2 + s[j] = 0 + while j < half: + s[j] = 0 + j += m + i = i+1 + m = 2*i+3 + return [2]+[x for x in s if x] + + +def generate_n_Primes(n): + primes = [] + chkthis = 2 + while len(primes) < n: + ptest = [chkthis for i in primes if chkthis%i == 0] + primes += [] if ptest else [chkthis] + chkthis += 1 + return primes + + + +def circular_primes(n): + primes = generatePrimes(n) + count = 0 + for prime in primes: + if isCircular(prime): + count += 1 + return count + + +def main(): + import time + start = time.time() + + print(circular_primes(1000000)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/046-gold_other.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/046-gold_other.py new file mode 100644 index 0000000..5b471e4 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/046-gold_other.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def isPrime(n): + n = abs(int(n)) + if n < 2: + return False + if n == 2: + return True + if not n & 1: + return False + for x in range(3, int(n**0.5)+1, 2): + if n % x == 0: + return False + return True + + +def generetePrimes(n): + if n == 2: return [2] + elif n < 2: return [] + s = [i for i in range(3, n+1,2)] + mroot = n ** 0.5 + half = (n+1)//2-1 + i = 0 + m = 3 + while m <= mroot: + if s[i]: + j = (m*m - 3)//2 + s[j] = 0 + while j < half: + s[j] = 0 + j += m + i = i+1 + m = 2*i+3 + return [2]+[x for x in s if x] + + +def gold_other(n): + primes_for_n = generetePrimes(n) + numbers = {prime + 2*x**2 for prime in primes_for_n for x in range(1, int(n**0.5))} + conj = {x for x in range(3, n, 2) if not isPrime(x)} + + while True: + candidates = conj - numbers + if not candidates: + gold_other(2*n) + else: + return min(candidates) + + + +def main(): + import time + start = time.time() + + print(gold_other(10000)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/048-self_powers.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/048-self_powers.py new file mode 100644 index 0000000..1fb2420 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/048-self_powers.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def self_powers(power, digits): + sum_total = 0 + for pow in range(1, power+1): + sum_total += pow**pow + sum_total_str = str(sum_total) + last_digits = '' + for i, c in enumerate(sum_total_str[-digits:]): + last_digits += c + return int(last_digits) + + +def main(): + import time + start = time.time() + + + assert(self_powers(10, len('10405071317')) == 10405071317) + print(self_powers(1000, 10)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/065-100th-e-numerator.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/065-100th-e-numerator.py new file mode 100644 index 0000000..42a50fe --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/065-100th-e-numerator.py @@ -0,0 +1,43 @@ +#!/usr/bin/python + +__author__ = "Mari Wahl" +__email__ = "marina.w4hl@gmail.com" + +''' +e = [2; 1,2,1, 1,4,1, 1,6,1 , ... , 1,2k,1, ...]. + +The first ten terms in the sequence of convergents for e are: + +2, 3, 8/3, 11/4, 19/7, 87/32, 106/39, 193/71, 1264/465, 1457/536, ... +The sum of digits in the numerator of the 10th convergent is 1+4+5+7=17. + +Find the sum of digits in the numerator of the 100th convergent of the continued fraction for e. +''' + +from itertools import islice + +def take(iterable, n): + #Make an iterator that returns selected elements from the iterable. + return list(islice(iterable, n)) + +def e(): + yield 2 + k = 1 + while True: + yield 1 + yield 2*k + yield 1 + k += 1 + +def rationalize(frac): + if len(frac) == 0: + return (1, 0) + elif len(frac) == 1: + return (frac[0], 1) + else: + remainder = frac[1:len(frac)] + (num, denom) = rationalize(remainder) + return (frac[0] * num + denom, num) + +numerator = rationalize(take(e(), 100))[0] +print sum(int(d) for d in str(numerator)) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/089-roman_numbers.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/089-roman_numbers.py new file mode 100644 index 0000000..9220261 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/089-roman_numbers.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +__author__ = "Mari Wahl" +__email__ = "marina.w4hl@gmail.com" + +''' +The rules for writing Roman numerals allow for many ways of writing each number (see About Roman Numerals...). However, there is always a "best" way of writing a particular number. + +For example, the following represent all of the legitimate ways of writing the number sixteen: + +IIIIIIIIIIIIIIII +VIIIIIIIIIII +VVIIIIII +XIIIIII +VVVI +XVI + +The last example being considered the most efficient, as it uses the least number of numerals. + +The 11K text file, roman.txt (right click and 'Save Link/Target As...'), contains one thousand numbers written in valid, but not necessarily minimal, Roman numerals; that is, they are arranged in descending units and obey the subtractive pair rule (see About Roman Numerals... for the definitive rules for this problem). + +Find the number of characters saved by writing each of these in their minimal form. +''' + + + +import os + +def subtractive(roman): + result = roman + replacements = [ + ("VIIII", "IX"), + ("IIII", "IV"), + ("LXXXX", "XC"), + ("XXXX", "XL"), + ("DCCCC", "CM"), + ("CCCC", "CD"), + ] + for old, new in replacements: + result = result.replace(old, new) + return result + + +if __name__ == '__main__': + + current = 0 + improved = 0 + for line in open(os.path.join(os.path.dirname(__file__), 'roman.txt')): + roman = line.strip() + current += len(roman) + improved += len(subtractive(roman)) + print current - improved \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/092-square_dig_chains.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/092-square_dig_chains.py new file mode 100644 index 0000000..12b67b2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/092-square_dig_chains.py @@ -0,0 +1,38 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + +def calculate_chain(n): + n_str = str(n) + while n_str != 1 or n_str != 89: + n_str = str(n_str) + sum_here = 0 + for d in n_str: + sum_here += int(d)**2 + n_str = sum_here + if n_str == 89: + return 1 + if n_str == 1: + return 0 + + +def square_dig_chains(n): + count = 0 + for i in range(1, n+1): + count += calculate_chain(i) + return count + + + +def main(): + import time + start = time.time() + + print(square_dig_chains(10**7)) + + elapsed = (time.time() - start) + print('Tests Passed!\n It took %s seconds to run them.' % (elapsed)) + +if __name__ == '__main__': + main() + diff --git a/LICENSE b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/LICENSE similarity index 100% rename from LICENSE rename to MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/LICENSE diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/README.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/README.md new file mode 100644 index 0000000..e503da3 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/README.md @@ -0,0 +1,23 @@ +# šŸŸ Project Euler Solutions šŸŸ + +Several of my solutions for the Euler project. For fun or profit :) + +Most of the exercises are written in Python, but I have some Java and Clojure too. + +Enjoy! + +![](http://projecteuler.net/profile/bytegirl.png) + + + + +---- + + +## License + +When making a reference to my work, please use my [website](http://bt3gl.github.io/index.html). + +Creative Commons License
+ +This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/larg_prod_grid.dat b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/larg_prod_grid.dat new file mode 100644 index 0000000..4ac2451 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/larg_prod_grid.dat @@ -0,0 +1,20 @@ +08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 +49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 +81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 +52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 +22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 +24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 +32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 +67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21 +24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72 +21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95 +78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92 +16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57 +86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58 +19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40 +04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66 +88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69 +04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36 +20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16 +20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54 +01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48 diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/large_sum.dat b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/large_sum.dat new file mode 100644 index 0000000..43b568e --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/large_sum.dat @@ -0,0 +1,100 @@ +37107287533902102798797998220837590246510135740250 +46376937677490009712648124896970078050417018260538 +74324986199524741059474233309513058123726617309629 +91942213363574161572522430563301811072406154908250 +23067588207539346171171980310421047513778063246676 +89261670696623633820136378418383684178734361726757 +28112879812849979408065481931592621691275889832738 +44274228917432520321923589422876796487670272189318 +47451445736001306439091167216856844588711603153276 +70386486105843025439939619828917593665686757934951 +62176457141856560629502157223196586755079324193331 +64906352462741904929101432445813822663347944758178 +92575867718337217661963751590579239728245598838407 +58203565325359399008402633568948830189458628227828 +80181199384826282014278194139940567587151170094390 +35398664372827112653829987240784473053190104293586 +86515506006295864861532075273371959191420517255829 +71693888707715466499115593487603532921714970056938 +54370070576826684624621495650076471787294438377604 +53282654108756828443191190634694037855217779295145 +36123272525000296071075082563815656710885258350721 +45876576172410976447339110607218265236877223636045 +17423706905851860660448207621209813287860733969412 +81142660418086830619328460811191061556940512689692 +51934325451728388641918047049293215058642563049483 +62467221648435076201727918039944693004732956340691 +15732444386908125794514089057706229429197107928209 +55037687525678773091862540744969844508330393682126 +18336384825330154686196124348767681297534375946515 +80386287592878490201521685554828717201219257766954 +78182833757993103614740356856449095527097864797581 +16726320100436897842553539920931837441497806860984 +48403098129077791799088218795327364475675590848030 +87086987551392711854517078544161852424320693150332 +59959406895756536782107074926966537676326235447210 +69793950679652694742597709739166693763042633987085 +41052684708299085211399427365734116182760315001271 +65378607361501080857009149939512557028198746004375 +35829035317434717326932123578154982629742552737307 +94953759765105305946966067683156574377167401875275 +88902802571733229619176668713819931811048770190271 +25267680276078003013678680992525463401061632866526 +36270218540497705585629946580636237993140746255962 +24074486908231174977792365466257246923322810917141 +91430288197103288597806669760892938638285025333403 +34413065578016127815921815005561868836468420090470 +23053081172816430487623791969842487255036638784583 +11487696932154902810424020138335124462181441773470 +63783299490636259666498587618221225225512486764533 +67720186971698544312419572409913959008952310058822 +95548255300263520781532296796249481641953868218774 +76085327132285723110424803456124867697064507995236 +37774242535411291684276865538926205024910326572967 +23701913275725675285653248258265463092207058596522 +29798860272258331913126375147341994889534765745501 +18495701454879288984856827726077713721403798879715 +38298203783031473527721580348144513491373226651381 +34829543829199918180278916522431027392251122869539 +40957953066405232632538044100059654939159879593635 +29746152185502371307642255121183693803580388584903 +41698116222072977186158236678424689157993532961922 +62467957194401269043877107275048102390895523597457 +23189706772547915061505504953922979530901129967519 +86188088225875314529584099251203829009407770775672 +11306739708304724483816533873502340845647058077308 +82959174767140363198008187129011875491310547126581 +97623331044818386269515456334926366572897563400500 +42846280183517070527831839425882145521227251250327 +55121603546981200581762165212827652751691296897789 +32238195734329339946437501907836945765883352399886 +75506164965184775180738168837861091527357929701337 +62177842752192623401942399639168044983993173312731 +32924185707147349566916674687634660915035914677504 +99518671430235219628894890102423325116913619626622 +73267460800591547471830798392868535206946944540724 +76841822524674417161514036427982273348055556214818 +97142617910342598647204516893989422179826088076852 +87783646182799346313767754307809363333018982642090 +10848802521674670883215120185883543223812876952786 +71329612474782464538636993009049310363619763878039 +62184073572399794223406235393808339651327408011116 +66627891981488087797941876876144230030984490851411 +60661826293682836764744779239180335110989069790714 +85786944089552990653640447425576083659976645795096 +66024396409905389607120198219976047599490197230297 +64913982680032973156037120041377903785566085089252 +16730939319872750275468906903707539413042652315011 +94809377245048795150954100921645863754710598436791 +78639167021187492431995700641917969777599028300699 +15368713711936614952811305876380278410754449733078 +40789923115535562561142322423255033685442488917353 +44889911501440648020369068063960672322193204149535 +41503128880339536053299340368006977710650566631954 +81234880673210146739058568557934581403627822703280 +82616570773948327592232845941706525094512325230608 +22918802058777319719839450180888072429661980811197 +77158542502016545090413245809786882778948721859617 +72107838435069186155435662884062257473692284509516 +20849603980134001723930671666823555245252804609722 +53503534226472524250874054075591789781264330331690 diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/max_path_sum.dat b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/max_path_sum.dat new file mode 100644 index 0000000..e236c2f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/max_path_sum.dat @@ -0,0 +1,15 @@ +75 +95 64 +17 47 82 +18 35 87 10 +20 04 82 47 65 +19 01 23 75 03 34 +88 02 77 73 07 63 67 +99 65 04 28 06 16 70 92 +41 41 26 56 83 40 80 70 33 +41 48 72 33 47 32 37 16 94 29 +53 71 44 65 25 43 91 52 97 51 14 +70 11 33 28 77 73 17 78 39 68 17 57 +91 71 52 38 17 14 91 43 58 50 27 29 48 +63 66 04 68 89 53 67 30 73 16 69 87 40 31 +04 62 98 27 23 09 70 98 73 93 38 53 60 04 23 diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/max_path_sum0.dat b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/max_path_sum0.dat new file mode 100644 index 0000000..65ff300 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/max_path_sum0.dat @@ -0,0 +1,4 @@ +3 +7 4 +2 4 6 +8 5 9 3 diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/names.txt b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/names.txt new file mode 100644 index 0000000..7b8986b --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/names.txt @@ -0,0 +1 @@ +"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KATHLEEN","PAMELA","MARTHA","DEBRA","AMANDA","STEPHANIE","CAROLYN","CHRISTINE","MARIE","JANET","CATHERINE","FRANCES","ANN","JOYCE","DIANE","ALICE","JULIE","HEATHER","TERESA","DORIS","GLORIA","EVELYN","JEAN","CHERYL","MILDRED","KATHERINE","JOAN","ASHLEY","JUDITH","ROSE","JANICE","KELLY","NICOLE","JUDY","CHRISTINA","KATHY","THERESA","BEVERLY","DENISE","TAMMY","IRENE","JANE","LORI","RACHEL","MARILYN","ANDREA","KATHRYN","LOUISE","SARA","ANNE","JACQUELINE","WANDA","BONNIE","JULIA","RUBY","LOIS","TINA","PHYLLIS","NORMA","PAULA","DIANA","ANNIE","LILLIAN","EMILY","ROBIN","PEGGY","CRYSTAL","GLADYS","RITA","DAWN","CONNIE","FLORENCE","TRACY","EDNA","TIFFANY","CARMEN","ROSA","CINDY","GRACE","WENDY","VICTORIA","EDITH","KIM","SHERRY","SYLVIA","JOSEPHINE","THELMA","SHANNON","SHEILA","ETHEL","ELLEN","ELAINE","MARJORIE","CARRIE","CHARLOTTE","MONICA","ESTHER","PAULINE","EMMA","JUANITA","ANITA","RHONDA","HAZEL","AMBER","EVA","DEBBIE","APRIL","LESLIE","CLARA","LUCILLE","JAMIE","JOANNE","ELEANOR","VALERIE","DANIELLE","MEGAN","ALICIA","SUZANNE","MICHELE","GAIL","BERTHA","DARLENE","VERONICA","JILL","ERIN","GERALDINE","LAUREN","CATHY","JOANN","LORRAINE","LYNN","SALLY","REGINA","ERICA","BEATRICE","DOLORES","BERNICE","AUDREY","YVONNE","ANNETTE","JUNE","SAMANTHA","MARION","DANA","STACY","ANA","RENEE","IDA","VIVIAN","ROBERTA","HOLLY","BRITTANY","MELANIE","LORETTA","YOLANDA","JEANETTE","LAURIE","KATIE","KRISTEN","VANESSA","ALMA","SUE","ELSIE","BETH","JEANNE","VICKI","CARLA","TARA","ROSEMARY","EILEEN","TERRI","GERTRUDE","LUCY","TONYA","ELLA","STACEY","WILMA","GINA","KRISTIN","JESSIE","NATALIE","AGNES","VERA","WILLIE","CHARLENE","BESSIE","DELORES","MELINDA","PEARL","ARLENE","MAUREEN","COLLEEN","ALLISON","TAMARA","JOY","GEORGIA","CONSTANCE","LILLIE","CLAUDIA","JACKIE","MARCIA","TANYA","NELLIE","MINNIE","MARLENE","HEIDI","GLENDA","LYDIA","VIOLA","COURTNEY","MARIAN","STELLA","CAROLINE","DORA","JO","VICKIE","MATTIE","TERRY","MAXINE","IRMA","MABEL","MARSHA","MYRTLE","LENA","CHRISTY","DEANNA","PATSY","HILDA","GWENDOLYN","JENNIE","NORA","MARGIE","NINA","CASSANDRA","LEAH","PENNY","KAY","PRISCILLA","NAOMI","CAROLE","BRANDY","OLGA","BILLIE","DIANNE","TRACEY","LEONA","JENNY","FELICIA","SONIA","MIRIAM","VELMA","BECKY","BOBBIE","VIOLET","KRISTINA","TONI","MISTY","MAE","SHELLY","DAISY","RAMONA","SHERRI","ERIKA","KATRINA","CLAIRE","LINDSEY","LINDSAY","GENEVA","GUADALUPE","BELINDA","MARGARITA","SHERYL","CORA","FAYE","ADA","NATASHA","SABRINA","ISABEL","MARGUERITE","HATTIE","HARRIET","MOLLY","CECILIA","KRISTI","BRANDI","BLANCHE","SANDY","ROSIE","JOANNA","IRIS","EUNICE","ANGIE","INEZ","LYNDA","MADELINE","AMELIA","ALBERTA","GENEVIEVE","MONIQUE","JODI","JANIE","MAGGIE","KAYLA","SONYA","JAN","LEE","KRISTINE","CANDACE","FANNIE","MARYANN","OPAL","ALISON","YVETTE","MELODY","LUZ","SUSIE","OLIVIA","FLORA","SHELLEY","KRISTY","MAMIE","LULA","LOLA","VERNA","BEULAH","ANTOINETTE","CANDICE","JUANA","JEANNETTE","PAM","KELLI","HANNAH","WHITNEY","BRIDGET","KARLA","CELIA","LATOYA","PATTY","SHELIA","GAYLE","DELLA","VICKY","LYNNE","SHERI","MARIANNE","KARA","JACQUELYN","ERMA","BLANCA","MYRA","LETICIA","PAT","KRISTA","ROXANNE","ANGELICA","JOHNNIE","ROBYN","FRANCIS","ADRIENNE","ROSALIE","ALEXANDRA","BROOKE","BETHANY","SADIE","BERNADETTE","TRACI","JODY","KENDRA","JASMINE","NICHOLE","RACHAEL","CHELSEA","MABLE","ERNESTINE","MURIEL","MARCELLA","ELENA","KRYSTAL","ANGELINA","NADINE","KARI","ESTELLE","DIANNA","PAULETTE","LORA","MONA","DOREEN","ROSEMARIE","ANGEL","DESIREE","ANTONIA","HOPE","GINGER","JANIS","BETSY","CHRISTIE","FREDA","MERCEDES","MEREDITH","LYNETTE","TERI","CRISTINA","EULA","LEIGH","MEGHAN","SOPHIA","ELOISE","ROCHELLE","GRETCHEN","CECELIA","RAQUEL","HENRIETTA","ALYSSA","JANA","KELLEY","GWEN","KERRY","JENNA","TRICIA","LAVERNE","OLIVE","ALEXIS","TASHA","SILVIA","ELVIRA","CASEY","DELIA","SOPHIE","KATE","PATTI","LORENA","KELLIE","SONJA","LILA","LANA","DARLA","MAY","MINDY","ESSIE","MANDY","LORENE","ELSA","JOSEFINA","JEANNIE","MIRANDA","DIXIE","LUCIA","MARTA","FAITH","LELA","JOHANNA","SHARI","CAMILLE","TAMI","SHAWNA","ELISA","EBONY","MELBA","ORA","NETTIE","TABITHA","OLLIE","JAIME","WINIFRED","KRISTIE","MARINA","ALISHA","AIMEE","RENA","MYRNA","MARLA","TAMMIE","LATASHA","BONITA","PATRICE","RONDA","SHERRIE","ADDIE","FRANCINE","DELORIS","STACIE","ADRIANA","CHERI","SHELBY","ABIGAIL","CELESTE","JEWEL","CARA","ADELE","REBEKAH","LUCINDA","DORTHY","CHRIS","EFFIE","TRINA","REBA","SHAWN","SALLIE","AURORA","LENORA","ETTA","LOTTIE","KERRI","TRISHA","NIKKI","ESTELLA","FRANCISCA","JOSIE","TRACIE","MARISSA","KARIN","BRITTNEY","JANELLE","LOURDES","LAUREL","HELENE","FERN","ELVA","CORINNE","KELSEY","INA","BETTIE","ELISABETH","AIDA","CAITLIN","INGRID","IVA","EUGENIA","CHRISTA","GOLDIE","CASSIE","MAUDE","JENIFER","THERESE","FRANKIE","DENA","LORNA","JANETTE","LATONYA","CANDY","MORGAN","CONSUELO","TAMIKA","ROSETTA","DEBORA","CHERIE","POLLY","DINA","JEWELL","FAY","JILLIAN","DOROTHEA","NELL","TRUDY","ESPERANZA","PATRICA","KIMBERLEY","SHANNA","HELENA","CAROLINA","CLEO","STEFANIE","ROSARIO","OLA","JANINE","MOLLIE","LUPE","ALISA","LOU","MARIBEL","SUSANNE","BETTE","SUSANA","ELISE","CECILE","ISABELLE","LESLEY","JOCELYN","PAIGE","JONI","RACHELLE","LEOLA","DAPHNE","ALTA","ESTER","PETRA","GRACIELA","IMOGENE","JOLENE","KEISHA","LACEY","GLENNA","GABRIELA","KERI","URSULA","LIZZIE","KIRSTEN","SHANA","ADELINE","MAYRA","JAYNE","JACLYN","GRACIE","SONDRA","CARMELA","MARISA","ROSALIND","CHARITY","TONIA","BEATRIZ","MARISOL","CLARICE","JEANINE","SHEENA","ANGELINE","FRIEDA","LILY","ROBBIE","SHAUNA","MILLIE","CLAUDETTE","CATHLEEN","ANGELIA","GABRIELLE","AUTUMN","KATHARINE","SUMMER","JODIE","STACI","LEA","CHRISTI","JIMMIE","JUSTINE","ELMA","LUELLA","MARGRET","DOMINIQUE","SOCORRO","RENE","MARTINA","MARGO","MAVIS","CALLIE","BOBBI","MARITZA","LUCILE","LEANNE","JEANNINE","DEANA","AILEEN","LORIE","LADONNA","WILLA","MANUELA","GALE","SELMA","DOLLY","SYBIL","ABBY","LARA","DALE","IVY","DEE","WINNIE","MARCY","LUISA","JERI","MAGDALENA","OFELIA","MEAGAN","AUDRA","MATILDA","LEILA","CORNELIA","BIANCA","SIMONE","BETTYE","RANDI","VIRGIE","LATISHA","BARBRA","GEORGINA","ELIZA","LEANN","BRIDGETTE","RHODA","HALEY","ADELA","NOLA","BERNADINE","FLOSSIE","ILA","GRETA","RUTHIE","NELDA","MINERVA","LILLY","TERRIE","LETHA","HILARY","ESTELA","VALARIE","BRIANNA","ROSALYN","EARLINE","CATALINA","AVA","MIA","CLARISSA","LIDIA","CORRINE","ALEXANDRIA","CONCEPCION","TIA","SHARRON","RAE","DONA","ERICKA","JAMI","ELNORA","CHANDRA","LENORE","NEVA","MARYLOU","MELISA","TABATHA","SERENA","AVIS","ALLIE","SOFIA","JEANIE","ODESSA","NANNIE","HARRIETT","LORAINE","PENELOPE","MILAGROS","EMILIA","BENITA","ALLYSON","ASHLEE","TANIA","TOMMIE","ESMERALDA","KARINA","EVE","PEARLIE","ZELMA","MALINDA","NOREEN","TAMEKA","SAUNDRA","HILLARY","AMIE","ALTHEA","ROSALINDA","JORDAN","LILIA","ALANA","GAY","CLARE","ALEJANDRA","ELINOR","MICHAEL","LORRIE","JERRI","DARCY","EARNESTINE","CARMELLA","TAYLOR","NOEMI","MARCIE","LIZA","ANNABELLE","LOUISA","EARLENE","MALLORY","CARLENE","NITA","SELENA","TANISHA","KATY","JULIANNE","JOHN","LAKISHA","EDWINA","MARICELA","MARGERY","KENYA","DOLLIE","ROXIE","ROSLYN","KATHRINE","NANETTE","CHARMAINE","LAVONNE","ILENE","KRIS","TAMMI","SUZETTE","CORINE","KAYE","JERRY","MERLE","CHRYSTAL","LINA","DEANNE","LILIAN","JULIANA","ALINE","LUANN","KASEY","MARYANNE","EVANGELINE","COLETTE","MELVA","LAWANDA","YESENIA","NADIA","MADGE","KATHIE","EDDIE","OPHELIA","VALERIA","NONA","MITZI","MARI","GEORGETTE","CLAUDINE","FRAN","ALISSA","ROSEANN","LAKEISHA","SUSANNA","REVA","DEIDRE","CHASITY","SHEREE","CARLY","JAMES","ELVIA","ALYCE","DEIRDRE","GENA","BRIANA","ARACELI","KATELYN","ROSANNE","WENDI","TESSA","BERTA","MARVA","IMELDA","MARIETTA","MARCI","LEONOR","ARLINE","SASHA","MADELYN","JANNA","JULIETTE","DEENA","AURELIA","JOSEFA","AUGUSTA","LILIANA","YOUNG","CHRISTIAN","LESSIE","AMALIA","SAVANNAH","ANASTASIA","VILMA","NATALIA","ROSELLA","LYNNETTE","CORINA","ALFREDA","LEANNA","CAREY","AMPARO","COLEEN","TAMRA","AISHA","WILDA","KARYN","CHERRY","QUEEN","MAURA","MAI","EVANGELINA","ROSANNA","HALLIE","ERNA","ENID","MARIANA","LACY","JULIET","JACKLYN","FREIDA","MADELEINE","MARA","HESTER","CATHRYN","LELIA","CASANDRA","BRIDGETT","ANGELITA","JANNIE","DIONNE","ANNMARIE","KATINA","BERYL","PHOEBE","MILLICENT","KATHERYN","DIANN","CARISSA","MARYELLEN","LIZ","LAURI","HELGA","GILDA","ADRIAN","RHEA","MARQUITA","HOLLIE","TISHA","TAMERA","ANGELIQUE","FRANCESCA","BRITNEY","KAITLIN","LOLITA","FLORINE","ROWENA","REYNA","TWILA","FANNY","JANELL","INES","CONCETTA","BERTIE","ALBA","BRIGITTE","ALYSON","VONDA","PANSY","ELBA","NOELLE","LETITIA","KITTY","DEANN","BRANDIE","LOUELLA","LETA","FELECIA","SHARLENE","LESA","BEVERLEY","ROBERT","ISABELLA","HERMINIA","TERRA","CELINA","TORI","OCTAVIA","JADE","DENICE","GERMAINE","SIERRA","MICHELL","CORTNEY","NELLY","DORETHA","SYDNEY","DEIDRA","MONIKA","LASHONDA","JUDI","CHELSEY","ANTIONETTE","MARGOT","BOBBY","ADELAIDE","NAN","LEEANN","ELISHA","DESSIE","LIBBY","KATHI","GAYLA","LATANYA","MINA","MELLISA","KIMBERLEE","JASMIN","RENAE","ZELDA","ELDA","MA","JUSTINA","GUSSIE","EMILIE","CAMILLA","ABBIE","ROCIO","KAITLYN","JESSE","EDYTHE","ASHLEIGH","SELINA","LAKESHA","GERI","ALLENE","PAMALA","MICHAELA","DAYNA","CARYN","ROSALIA","SUN","JACQULINE","REBECA","MARYBETH","KRYSTLE","IOLA","DOTTIE","BENNIE","BELLE","AUBREY","GRISELDA","ERNESTINA","ELIDA","ADRIANNE","DEMETRIA","DELMA","CHONG","JAQUELINE","DESTINY","ARLEEN","VIRGINA","RETHA","FATIMA","TILLIE","ELEANORE","CARI","TREVA","BIRDIE","WILHELMINA","ROSALEE","MAURINE","LATRICE","YONG","JENA","TARYN","ELIA","DEBBY","MAUDIE","JEANNA","DELILAH","CATRINA","SHONDA","HORTENCIA","THEODORA","TERESITA","ROBBIN","DANETTE","MARYJANE","FREDDIE","DELPHINE","BRIANNE","NILDA","DANNA","CINDI","BESS","IONA","HANNA","ARIEL","WINONA","VIDA","ROSITA","MARIANNA","WILLIAM","RACHEAL","GUILLERMINA","ELOISA","CELESTINE","CAREN","MALISSA","LONA","CHANTEL","SHELLIE","MARISELA","LEORA","AGATHA","SOLEDAD","MIGDALIA","IVETTE","CHRISTEN","ATHENA","JANEL","CHLOE","VEDA","PATTIE","TESSIE","TERA","MARILYNN","LUCRETIA","KARRIE","DINAH","DANIELA","ALECIA","ADELINA","VERNICE","SHIELA","PORTIA","MERRY","LASHAWN","DEVON","DARA","TAWANA","OMA","VERDA","CHRISTIN","ALENE","ZELLA","SANDI","RAFAELA","MAYA","KIRA","CANDIDA","ALVINA","SUZAN","SHAYLA","LYN","LETTIE","ALVA","SAMATHA","ORALIA","MATILDE","MADONNA","LARISSA","VESTA","RENITA","INDIA","DELOIS","SHANDA","PHILLIS","LORRI","ERLINDA","CRUZ","CATHRINE","BARB","ZOE","ISABELL","IONE","GISELA","CHARLIE","VALENCIA","ROXANNA","MAYME","KISHA","ELLIE","MELLISSA","DORRIS","DALIA","BELLA","ANNETTA","ZOILA","RETA","REINA","LAURETTA","KYLIE","CHRISTAL","PILAR","CHARLA","ELISSA","TIFFANI","TANA","PAULINA","LEOTA","BREANNA","JAYME","CARMEL","VERNELL","TOMASA","MANDI","DOMINGA","SANTA","MELODIE","LURA","ALEXA","TAMELA","RYAN","MIRNA","KERRIE","VENUS","NOEL","FELICITA","CRISTY","CARMELITA","BERNIECE","ANNEMARIE","TIARA","ROSEANNE","MISSY","CORI","ROXANA","PRICILLA","KRISTAL","JUNG","ELYSE","HAYDEE","ALETHA","BETTINA","MARGE","GILLIAN","FILOMENA","CHARLES","ZENAIDA","HARRIETTE","CARIDAD","VADA","UNA","ARETHA","PEARLINE","MARJORY","MARCELA","FLOR","EVETTE","ELOUISE","ALINA","TRINIDAD","DAVID","DAMARIS","CATHARINE","CARROLL","BELVA","NAKIA","MARLENA","LUANNE","LORINE","KARON","DORENE","DANITA","BRENNA","TATIANA","SAMMIE","LOUANN","LOREN","JULIANNA","ANDRIA","PHILOMENA","LUCILA","LEONORA","DOVIE","ROMONA","MIMI","JACQUELIN","GAYE","TONJA","MISTI","JOE","GENE","CHASTITY","STACIA","ROXANN","MICAELA","NIKITA","MEI","VELDA","MARLYS","JOHNNA","AURA","LAVERN","IVONNE","HAYLEY","NICKI","MAJORIE","HERLINDA","GEORGE","ALPHA","YADIRA","PERLA","GREGORIA","DANIEL","ANTONETTE","SHELLI","MOZELLE","MARIAH","JOELLE","CORDELIA","JOSETTE","CHIQUITA","TRISTA","LOUIS","LAQUITA","GEORGIANA","CANDI","SHANON","LONNIE","HILDEGARD","CECIL","VALENTINA","STEPHANY","MAGDA","KAROL","GERRY","GABRIELLA","TIANA","ROMA","RICHELLE","RAY","PRINCESS","OLETA","JACQUE","IDELLA","ALAINA","SUZANNA","JOVITA","BLAIR","TOSHA","RAVEN","NEREIDA","MARLYN","KYLA","JOSEPH","DELFINA","TENA","STEPHENIE","SABINA","NATHALIE","MARCELLE","GERTIE","DARLEEN","THEA","SHARONDA","SHANTEL","BELEN","VENESSA","ROSALINA","ONA","GENOVEVA","COREY","CLEMENTINE","ROSALBA","RENATE","RENATA","MI","IVORY","GEORGIANNA","FLOY","DORCAS","ARIANA","TYRA","THEDA","MARIAM","JULI","JESICA","DONNIE","VIKKI","VERLA","ROSELYN","MELVINA","JANNETTE","GINNY","DEBRAH","CORRIE","ASIA","VIOLETA","MYRTIS","LATRICIA","COLLETTE","CHARLEEN","ANISSA","VIVIANA","TWYLA","PRECIOUS","NEDRA","LATONIA","LAN","HELLEN","FABIOLA","ANNAMARIE","ADELL","SHARYN","CHANTAL","NIKI","MAUD","LIZETTE","LINDY","KIA","KESHA","JEANA","DANELLE","CHARLINE","CHANEL","CARROL","VALORIE","LIA","DORTHA","CRISTAL","SUNNY","LEONE","LEILANI","GERRI","DEBI","ANDRA","KESHIA","IMA","EULALIA","EASTER","DULCE","NATIVIDAD","LINNIE","KAMI","GEORGIE","CATINA","BROOK","ALDA","WINNIFRED","SHARLA","RUTHANN","MEAGHAN","MAGDALENE","LISSETTE","ADELAIDA","VENITA","TRENA","SHIRLENE","SHAMEKA","ELIZEBETH","DIAN","SHANTA","MICKEY","LATOSHA","CARLOTTA","WINDY","SOON","ROSINA","MARIANN","LEISA","JONNIE","DAWNA","CATHIE","BILLY","ASTRID","SIDNEY","LAUREEN","JANEEN","HOLLI","FAWN","VICKEY","TERESSA","SHANTE","RUBYE","MARCELINA","CHANDA","CARY","TERESE","SCARLETT","MARTY","MARNIE","LULU","LISETTE","JENIFFER","ELENOR","DORINDA","DONITA","CARMAN","BERNITA","ALTAGRACIA","ALETA","ADRIANNA","ZORAIDA","RONNIE","NICOLA","LYNDSEY","KENDALL","JANINA","CHRISSY","AMI","STARLA","PHYLIS","PHUONG","KYRA","CHARISSE","BLANCH","SANJUANITA","RONA","NANCI","MARILEE","MARANDA","CORY","BRIGETTE","SANJUANA","MARITA","KASSANDRA","JOYCELYN","IRA","FELIPA","CHELSIE","BONNY","MIREYA","LORENZA","KYONG","ILEANA","CANDELARIA","TONY","TOBY","SHERIE","OK","MARK","LUCIE","LEATRICE","LAKESHIA","GERDA","EDIE","BAMBI","MARYLIN","LAVON","HORTENSE","GARNET","EVIE","TRESSA","SHAYNA","LAVINA","KYUNG","JEANETTA","SHERRILL","SHARA","PHYLISS","MITTIE","ANABEL","ALESIA","THUY","TAWANDA","RICHARD","JOANIE","TIFFANIE","LASHANDA","KARISSA","ENRIQUETA","DARIA","DANIELLA","CORINNA","ALANNA","ABBEY","ROXANE","ROSEANNA","MAGNOLIA","LIDA","KYLE","JOELLEN","ERA","CORAL","CARLEEN","TRESA","PEGGIE","NOVELLA","NILA","MAYBELLE","JENELLE","CARINA","NOVA","MELINA","MARQUERITE","MARGARETTE","JOSEPHINA","EVONNE","DEVIN","CINTHIA","ALBINA","TOYA","TAWNYA","SHERITA","SANTOS","MYRIAM","LIZABETH","LISE","KEELY","JENNI","GISELLE","CHERYLE","ARDITH","ARDIS","ALESHA","ADRIANE","SHAINA","LINNEA","KAROLYN","HONG","FLORIDA","FELISHA","DORI","DARCI","ARTIE","ARMIDA","ZOLA","XIOMARA","VERGIE","SHAMIKA","NENA","NANNETTE","MAXIE","LOVIE","JEANE","JAIMIE","INGE","FARRAH","ELAINA","CAITLYN","STARR","FELICITAS","CHERLY","CARYL","YOLONDA","YASMIN","TEENA","PRUDENCE","PENNIE","NYDIA","MACKENZIE","ORPHA","MARVEL","LIZBETH","LAURETTE","JERRIE","HERMELINDA","CAROLEE","TIERRA","MIRIAN","META","MELONY","KORI","JENNETTE","JAMILA","ENA","ANH","YOSHIKO","SUSANNAH","SALINA","RHIANNON","JOLEEN","CRISTINE","ASHTON","ARACELY","TOMEKA","SHALONDA","MARTI","LACIE","KALA","JADA","ILSE","HAILEY","BRITTANI","ZONA","SYBLE","SHERRYL","RANDY","NIDIA","MARLO","KANDICE","KANDI","DEB","DEAN","AMERICA","ALYCIA","TOMMY","RONNA","NORENE","MERCY","JOSE","INGEBORG","GIOVANNA","GEMMA","CHRISTEL","AUDRY","ZORA","VITA","VAN","TRISH","STEPHAINE","SHIRLEE","SHANIKA","MELONIE","MAZIE","JAZMIN","INGA","HOA","HETTIE","GERALYN","FONDA","ESTRELLA","ADELLA","SU","SARITA","RINA","MILISSA","MARIBETH","GOLDA","EVON","ETHELYN","ENEDINA","CHERISE","CHANA","VELVA","TAWANNA","SADE","MIRTA","LI","KARIE","JACINTA","ELNA","DAVINA","CIERRA","ASHLIE","ALBERTHA","TANESHA","STEPHANI","NELLE","MINDI","LU","LORINDA","LARUE","FLORENE","DEMETRA","DEDRA","CIARA","CHANTELLE","ASHLY","SUZY","ROSALVA","NOELIA","LYDA","LEATHA","KRYSTYNA","KRISTAN","KARRI","DARLINE","DARCIE","CINDA","CHEYENNE","CHERRIE","AWILDA","ALMEDA","ROLANDA","LANETTE","JERILYN","GISELE","EVALYN","CYNDI","CLETA","CARIN","ZINA","ZENA","VELIA","TANIKA","PAUL","CHARISSA","THOMAS","TALIA","MARGARETE","LAVONDA","KAYLEE","KATHLENE","JONNA","IRENA","ILONA","IDALIA","CANDIS","CANDANCE","BRANDEE","ANITRA","ALIDA","SIGRID","NICOLETTE","MARYJO","LINETTE","HEDWIG","CHRISTIANA","CASSIDY","ALEXIA","TRESSIE","MODESTA","LUPITA","LITA","GLADIS","EVELIA","DAVIDA","CHERRI","CECILY","ASHELY","ANNABEL","AGUSTINA","WANITA","SHIRLY","ROSAURA","HULDA","EUN","BAILEY","YETTA","VERONA","THOMASINA","SIBYL","SHANNAN","MECHELLE","LUE","LEANDRA","LANI","KYLEE","KANDY","JOLYNN","FERNE","EBONI","CORENE","ALYSIA","ZULA","NADA","MOIRA","LYNDSAY","LORRETTA","JUAN","JAMMIE","HORTENSIA","GAYNELL","CAMERON","ADRIA","VINA","VICENTA","TANGELA","STEPHINE","NORINE","NELLA","LIANA","LESLEE","KIMBERELY","ILIANA","GLORY","FELICA","EMOGENE","ELFRIEDE","EDEN","EARTHA","CARMA","BEA","OCIE","MARRY","LENNIE","KIARA","JACALYN","CARLOTA","ARIELLE","YU","STAR","OTILIA","KIRSTIN","KACEY","JOHNETTA","JOEY","JOETTA","JERALDINE","JAUNITA","ELANA","DORTHEA","CAMI","AMADA","ADELIA","VERNITA","TAMAR","SIOBHAN","RENEA","RASHIDA","OUIDA","ODELL","NILSA","MERYL","KRISTYN","JULIETA","DANICA","BREANNE","AUREA","ANGLEA","SHERRON","ODETTE","MALIA","LORELEI","LIN","LEESA","KENNA","KATHLYN","FIONA","CHARLETTE","SUZIE","SHANTELL","SABRA","RACQUEL","MYONG","MIRA","MARTINE","LUCIENNE","LAVADA","JULIANN","JOHNIE","ELVERA","DELPHIA","CLAIR","CHRISTIANE","CHAROLETTE","CARRI","AUGUSTINE","ASHA","ANGELLA","PAOLA","NINFA","LEDA","LAI","EDA","SUNSHINE","STEFANI","SHANELL","PALMA","MACHELLE","LISSA","KECIA","KATHRYNE","KARLENE","JULISSA","JETTIE","JENNIFFER","HUI","CORRINA","CHRISTOPHER","CAROLANN","ALENA","TESS","ROSARIA","MYRTICE","MARYLEE","LIANE","KENYATTA","JUDIE","JANEY","IN","ELMIRA","ELDORA","DENNA","CRISTI","CATHI","ZAIDA","VONNIE","VIVA","VERNIE","ROSALINE","MARIELA","LUCIANA","LESLI","KARAN","FELICE","DENEEN","ADINA","WYNONA","TARSHA","SHERON","SHASTA","SHANITA","SHANI","SHANDRA","RANDA","PINKIE","PARIS","NELIDA","MARILOU","LYLA","LAURENE","LACI","JOI","JANENE","DOROTHA","DANIELE","DANI","CAROLYNN","CARLYN","BERENICE","AYESHA","ANNELIESE","ALETHEA","THERSA","TAMIKO","RUFINA","OLIVA","MOZELL","MARYLYN","MADISON","KRISTIAN","KATHYRN","KASANDRA","KANDACE","JANAE","GABRIEL","DOMENICA","DEBBRA","DANNIELLE","CHUN","BUFFY","BARBIE","ARCELIA","AJA","ZENOBIA","SHAREN","SHAREE","PATRICK","PAGE","MY","LAVINIA","KUM","KACIE","JACKELINE","HUONG","FELISA","EMELIA","ELEANORA","CYTHIA","CRISTIN","CLYDE","CLARIBEL","CARON","ANASTACIA","ZULMA","ZANDRA","YOKO","TENISHA","SUSANN","SHERILYN","SHAY","SHAWANDA","SABINE","ROMANA","MATHILDA","LINSEY","KEIKO","JOANA","ISELA","GRETTA","GEORGETTA","EUGENIE","DUSTY","DESIRAE","DELORA","CORAZON","ANTONINA","ANIKA","WILLENE","TRACEE","TAMATHA","REGAN","NICHELLE","MICKIE","MAEGAN","LUANA","LANITA","KELSIE","EDELMIRA","BREE","AFTON","TEODORA","TAMIE","SHENA","MEG","LINH","KELI","KACI","DANYELLE","BRITT","ARLETTE","ALBERTINE","ADELLE","TIFFINY","STORMY","SIMONA","NUMBERS","NICOLASA","NICHOL","NIA","NAKISHA","MEE","MAIRA","LOREEN","KIZZY","JOHNNY","JAY","FALLON","CHRISTENE","BOBBYE","ANTHONY","YING","VINCENZA","TANJA","RUBIE","RONI","QUEENIE","MARGARETT","KIMBERLI","IRMGARD","IDELL","HILMA","EVELINA","ESTA","EMILEE","DENNISE","DANIA","CARL","CARIE","ANTONIO","WAI","SANG","RISA","RIKKI","PARTICIA","MUI","MASAKO","MARIO","LUVENIA","LOREE","LONI","LIEN","KEVIN","GIGI","FLORENCIA","DORIAN","DENITA","DALLAS","CHI","BILLYE","ALEXANDER","TOMIKA","SHARITA","RANA","NIKOLE","NEOMA","MARGARITE","MADALYN","LUCINA","LAILA","KALI","JENETTE","GABRIELE","EVELYNE","ELENORA","CLEMENTINA","ALEJANDRINA","ZULEMA","VIOLETTE","VANNESSA","THRESA","RETTA","PIA","PATIENCE","NOELLA","NICKIE","JONELL","DELTA","CHUNG","CHAYA","CAMELIA","BETHEL","ANYA","ANDREW","THANH","SUZANN","SPRING","SHU","MILA","LILLA","LAVERNA","KEESHA","KATTIE","GIA","GEORGENE","EVELINE","ESTELL","ELIZBETH","VIVIENNE","VALLIE","TRUDIE","STEPHANE","MICHEL","MAGALY","MADIE","KENYETTA","KARREN","JANETTA","HERMINE","HARMONY","DRUCILLA","DEBBI","CELESTINA","CANDIE","BRITNI","BECKIE","AMINA","ZITA","YUN","YOLANDE","VIVIEN","VERNETTA","TRUDI","SOMMER","PEARLE","PATRINA","OSSIE","NICOLLE","LOYCE","LETTY","LARISA","KATHARINA","JOSELYN","JONELLE","JENELL","IESHA","HEIDE","FLORINDA","FLORENTINA","FLO","ELODIA","DORINE","BRUNILDA","BRIGID","ASHLI","ARDELLA","TWANA","THU","TARAH","SUNG","SHEA","SHAVON","SHANE","SERINA","RAYNA","RAMONITA","NGA","MARGURITE","LUCRECIA","KOURTNEY","KATI","JESUS","JESENIA","DIAMOND","CRISTA","AYANA","ALICA","ALIA","VINNIE","SUELLEN","ROMELIA","RACHELL","PIPER","OLYMPIA","MICHIKO","KATHALEEN","JOLIE","JESSI","JANESSA","HANA","HA","ELEASE","CARLETTA","BRITANY","SHONA","SALOME","ROSAMOND","REGENA","RAINA","NGOC","NELIA","LOUVENIA","LESIA","LATRINA","LATICIA","LARHONDA","JINA","JACKI","HOLLIS","HOLLEY","EMMY","DEEANN","CORETTA","ARNETTA","VELVET","THALIA","SHANICE","NETA","MIKKI","MICKI","LONNA","LEANA","LASHUNDA","KILEY","JOYE","JACQULYN","IGNACIA","HYUN","HIROKO","HENRY","HENRIETTE","ELAYNE","DELINDA","DARNELL","DAHLIA","COREEN","CONSUELA","CONCHITA","CELINE","BABETTE","AYANNA","ANETTE","ALBERTINA","SKYE","SHAWNEE","SHANEKA","QUIANA","PAMELIA","MIN","MERRI","MERLENE","MARGIT","KIESHA","KIERA","KAYLENE","JODEE","JENISE","ERLENE","EMMIE","ELSE","DARYL","DALILA","DAISEY","CODY","CASIE","BELIA","BABARA","VERSIE","VANESA","SHELBA","SHAWNDA","SAM","NORMAN","NIKIA","NAOMA","MARNA","MARGERET","MADALINE","LAWANA","KINDRA","JUTTA","JAZMINE","JANETT","HANNELORE","GLENDORA","GERTRUD","GARNETT","FREEDA","FREDERICA","FLORANCE","FLAVIA","DENNIS","CARLINE","BEVERLEE","ANJANETTE","VALDA","TRINITY","TAMALA","STEVIE","SHONNA","SHA","SARINA","ONEIDA","MICAH","MERILYN","MARLEEN","LURLINE","LENNA","KATHERIN","JIN","JENI","HAE","GRACIA","GLADY","FARAH","ERIC","ENOLA","EMA","DOMINQUE","DEVONA","DELANA","CECILA","CAPRICE","ALYSHA","ALI","ALETHIA","VENA","THERESIA","TAWNY","SONG","SHAKIRA","SAMARA","SACHIKO","RACHELE","PAMELLA","NICKY","MARNI","MARIEL","MAREN","MALISA","LIGIA","LERA","LATORIA","LARAE","KIMBER","KATHERN","KAREY","JENNEFER","JANETH","HALINA","FREDIA","DELISA","DEBROAH","CIERA","CHIN","ANGELIKA","ANDREE","ALTHA","YEN","VIVAN","TERRESA","TANNA","SUK","SUDIE","SOO","SIGNE","SALENA","RONNI","REBBECCA","MYRTIE","MCKENZIE","MALIKA","MAIDA","LOAN","LEONARDA","KAYLEIGH","FRANCE","ETHYL","ELLYN","DAYLE","CAMMIE","BRITTNI","BIRGIT","AVELINA","ASUNCION","ARIANNA","AKIKO","VENICE","TYESHA","TONIE","TIESHA","TAKISHA","STEFFANIE","SINDY","SANTANA","MEGHANN","MANDA","MACIE","LADY","KELLYE","KELLEE","JOSLYN","JASON","INGER","INDIRA","GLINDA","GLENNIS","FERNANDA","FAUSTINA","ENEIDA","ELICIA","DOT","DIGNA","DELL","ARLETTA","ANDRE","WILLIA","TAMMARA","TABETHA","SHERRELL","SARI","REFUGIO","REBBECA","PAULETTA","NIEVES","NATOSHA","NAKITA","MAMMIE","KENISHA","KAZUKO","KASSIE","GARY","EARLEAN","DAPHINE","CORLISS","CLOTILDE","CAROLYNE","BERNETTA","AUGUSTINA","AUDREA","ANNIS","ANNABELL","YAN","TENNILLE","TAMICA","SELENE","SEAN","ROSANA","REGENIA","QIANA","MARKITA","MACY","LEEANNE","LAURINE","KYM","JESSENIA","JANITA","GEORGINE","GENIE","EMIKO","ELVIE","DEANDRA","DAGMAR","CORIE","COLLEN","CHERISH","ROMAINE","PORSHA","PEARLENE","MICHELINE","MERNA","MARGORIE","MARGARETTA","LORE","KENNETH","JENINE","HERMINA","FREDERICKA","ELKE","DRUSILLA","DORATHY","DIONE","DESIRE","CELENA","BRIGIDA","ANGELES","ALLEGRA","THEO","TAMEKIA","SYNTHIA","STEPHEN","SOOK","SLYVIA","ROSANN","REATHA","RAYE","MARQUETTA","MARGART","LING","LAYLA","KYMBERLY","KIANA","KAYLEEN","KATLYN","KARMEN","JOELLA","IRINA","EMELDA","ELENI","DETRA","CLEMMIE","CHERYLL","CHANTELL","CATHEY","ARNITA","ARLA","ANGLE","ANGELIC","ALYSE","ZOFIA","THOMASINE","TENNIE","SON","SHERLY","SHERLEY","SHARYL","REMEDIOS","PETRINA","NICKOLE","MYUNG","MYRLE","MOZELLA","LOUANNE","LISHA","LATIA","LANE","KRYSTA","JULIENNE","JOEL","JEANENE","JACQUALINE","ISAURA","GWENDA","EARLEEN","DONALD","CLEOPATRA","CARLIE","AUDIE","ANTONIETTA","ALISE","ALEX","VERDELL","VAL","TYLER","TOMOKO","THAO","TALISHA","STEVEN","SO","SHEMIKA","SHAUN","SCARLET","SAVANNA","SANTINA","ROSIA","RAEANN","ODILIA","NANA","MINNA","MAGAN","LYNELLE","LE","KARMA","JOEANN","IVANA","INELL","ILANA","HYE","HONEY","HEE","GUDRUN","FRANK","DREAMA","CRISSY","CHANTE","CARMELINA","ARVILLA","ARTHUR","ANNAMAE","ALVERA","ALEIDA","AARON","YEE","YANIRA","VANDA","TIANNA","TAM","STEFANIA","SHIRA","PERRY","NICOL","NANCIE","MONSERRATE","MINH","MELYNDA","MELANY","MATTHEW","LOVELLA","LAURE","KIRBY","KACY","JACQUELYNN","HYON","GERTHA","FRANCISCO","ELIANA","CHRISTENA","CHRISTEEN","CHARISE","CATERINA","CARLEY","CANDYCE","ARLENA","AMMIE","YANG","WILLETTE","VANITA","TUYET","TINY","SYREETA","SILVA","SCOTT","RONALD","PENNEY","NYLA","MICHAL","MAURICE","MARYAM","MARYA","MAGEN","LUDIE","LOMA","LIVIA","LANELL","KIMBERLIE","JULEE","DONETTA","DIEDRA","DENISHA","DEANE","DAWNE","CLARINE","CHERRYL","BRONWYN","BRANDON","ALLA","VALERY","TONDA","SUEANN","SORAYA","SHOSHANA","SHELA","SHARLEEN","SHANELLE","NERISSA","MICHEAL","MERIDITH","MELLIE","MAYE","MAPLE","MAGARET","LUIS","LILI","LEONILA","LEONIE","LEEANNA","LAVONIA","LAVERA","KRISTEL","KATHEY","KATHE","JUSTIN","JULIAN","JIMMY","JANN","ILDA","HILDRED","HILDEGARDE","GENIA","FUMIKO","EVELIN","ERMELINDA","ELLY","DUNG","DOLORIS","DIONNA","DANAE","BERNEICE","ANNICE","ALIX","VERENA","VERDIE","TRISTAN","SHAWNNA","SHAWANA","SHAUNNA","ROZELLA","RANDEE","RANAE","MILAGRO","LYNELL","LUISE","LOUIE","LOIDA","LISBETH","KARLEEN","JUNITA","JONA","ISIS","HYACINTH","HEDY","GWENN","ETHELENE","ERLINE","EDWARD","DONYA","DOMONIQUE","DELICIA","DANNETTE","CICELY","BRANDA","BLYTHE","BETHANN","ASHLYN","ANNALEE","ALLINE","YUKO","VELLA","TRANG","TOWANDA","TESHA","SHERLYN","NARCISA","MIGUELINA","MERI","MAYBELL","MARLANA","MARGUERITA","MADLYN","LUNA","LORY","LORIANN","LIBERTY","LEONORE","LEIGHANN","LAURICE","LATESHA","LARONDA","KATRICE","KASIE","KARL","KALEY","JADWIGA","GLENNIE","GEARLDINE","FRANCINA","EPIFANIA","DYAN","DORIE","DIEDRE","DENESE","DEMETRICE","DELENA","DARBY","CRISTIE","CLEORA","CATARINA","CARISA","BERNIE","BARBERA","ALMETA","TRULA","TEREASA","SOLANGE","SHEILAH","SHAVONNE","SANORA","ROCHELL","MATHILDE","MARGARETA","MAIA","LYNSEY","LAWANNA","LAUNA","KENA","KEENA","KATIA","JAMEY","GLYNDA","GAYLENE","ELVINA","ELANOR","DANUTA","DANIKA","CRISTEN","CORDIE","COLETTA","CLARITA","CARMON","BRYNN","AZUCENA","AUNDREA","ANGELE","YI","WALTER","VERLIE","VERLENE","TAMESHA","SILVANA","SEBRINA","SAMIRA","REDA","RAYLENE","PENNI","PANDORA","NORAH","NOMA","MIREILLE","MELISSIA","MARYALICE","LARAINE","KIMBERY","KARYL","KARINE","KAM","JOLANDA","JOHANA","JESUSA","JALEESA","JAE","JACQUELYNE","IRISH","ILUMINADA","HILARIA","HANH","GENNIE","FRANCIE","FLORETTA","EXIE","EDDA","DREMA","DELPHA","BEV","BARBAR","ASSUNTA","ARDELL","ANNALISA","ALISIA","YUKIKO","YOLANDO","WONDA","WEI","WALTRAUD","VETA","TEQUILA","TEMEKA","TAMEIKA","SHIRLEEN","SHENITA","PIEDAD","OZELLA","MIRTHA","MARILU","KIMIKO","JULIANE","JENICE","JEN","JANAY","JACQUILINE","HILDE","FE","FAE","EVAN","EUGENE","ELOIS","ECHO","DEVORAH","CHAU","BRINDA","BETSEY","ARMINDA","ARACELIS","APRYL","ANNETT","ALISHIA","VEOLA","USHA","TOSHIKO","THEOLA","TASHIA","TALITHA","SHERY","RUDY","RENETTA","REIKO","RASHEEDA","OMEGA","OBDULIA","MIKA","MELAINE","MEGGAN","MARTIN","MARLEN","MARGET","MARCELINE","MANA","MAGDALEN","LIBRADA","LEZLIE","LEXIE","LATASHIA","LASANDRA","KELLE","ISIDRA","ISA","INOCENCIA","GWYN","FRANCOISE","ERMINIA","ERINN","DIMPLE","DEVORA","CRISELDA","ARMANDA","ARIE","ARIANE","ANGELO","ANGELENA","ALLEN","ALIZA","ADRIENE","ADALINE","XOCHITL","TWANNA","TRAN","TOMIKO","TAMISHA","TAISHA","SUSY","SIU","RUTHA","ROXY","RHONA","RAYMOND","OTHA","NORIKO","NATASHIA","MERRIE","MELVIN","MARINDA","MARIKO","MARGERT","LORIS","LIZZETTE","LEISHA","KAILA","KA","JOANNIE","JERRICA","JENE","JANNET","JANEE","JACINDA","HERTA","ELENORE","DORETTA","DELAINE","DANIELL","CLAUDIE","CHINA","BRITTA","APOLONIA","AMBERLY","ALEASE","YURI","YUK","WEN","WANETA","UTE","TOMI","SHARRI","SANDIE","ROSELLE","REYNALDA","RAGUEL","PHYLICIA","PATRIA","OLIMPIA","ODELIA","MITZIE","MITCHELL","MISS","MINDA","MIGNON","MICA","MENDY","MARIVEL","MAILE","LYNETTA","LAVETTE","LAURYN","LATRISHA","LAKIESHA","KIERSTEN","KARY","JOSPHINE","JOLYN","JETTA","JANISE","JACQUIE","IVELISSE","GLYNIS","GIANNA","GAYNELLE","EMERALD","DEMETRIUS","DANYELL","DANILLE","DACIA","CORALEE","CHER","CEOLA","BRETT","BELL","ARIANNE","ALESHIA","YUNG","WILLIEMAE","TROY","TRINH","THORA","TAI","SVETLANA","SHERIKA","SHEMEKA","SHAUNDA","ROSELINE","RICKI","MELDA","MALLIE","LAVONNA","LATINA","LARRY","LAQUANDA","LALA","LACHELLE","KLARA","KANDIS","JOHNA","JEANMARIE","JAYE","HANG","GRAYCE","GERTUDE","EMERITA","EBONIE","CLORINDA","CHING","CHERY","CAROLA","BREANN","BLOSSOM","BERNARDINE","BECKI","ARLETHA","ARGELIA","ARA","ALITA","YULANDA","YON","YESSENIA","TOBI","TASIA","SYLVIE","SHIRL","SHIRELY","SHERIDAN","SHELLA","SHANTELLE","SACHA","ROYCE","REBECKA","REAGAN","PROVIDENCIA","PAULENE","MISHA","MIKI","MARLINE","MARICA","LORITA","LATOYIA","LASONYA","KERSTIN","KENDA","KEITHA","KATHRIN","JAYMIE","JACK","GRICELDA","GINETTE","ERYN","ELINA","ELFRIEDA","DANYEL","CHEREE","CHANELLE","BARRIE","AVERY","AURORE","ANNAMARIA","ALLEEN","AILENE","AIDE","YASMINE","VASHTI","VALENTINE","TREASA","TORY","TIFFANEY","SHERYLL","SHARIE","SHANAE","SAU","RAISA","PA","NEDA","MITSUKO","MIRELLA","MILDA","MARYANNA","MARAGRET","MABELLE","LUETTA","LORINA","LETISHA","LATARSHA","LANELLE","LAJUANA","KRISSY","KARLY","KARENA","JON","JESSIKA","JERICA","JEANELLE","JANUARY","JALISA","JACELYN","IZOLA","IVEY","GREGORY","EUNA","ETHA","DREW","DOMITILA","DOMINICA","DAINA","CREOLA","CARLI","CAMIE","BUNNY","BRITTNY","ASHANTI","ANISHA","ALEEN","ADAH","YASUKO","WINTER","VIKI","VALRIE","TONA","TINISHA","THI","TERISA","TATUM","TANEKA","SIMONNE","SHALANDA","SERITA","RESSIE","REFUGIA","PAZ","OLENE","NA","MERRILL","MARGHERITA","MANDIE","MAN","MAIRE","LYNDIA","LUCI","LORRIANE","LORETA","LEONIA","LAVONA","LASHAWNDA","LAKIA","KYOKO","KRYSTINA","KRYSTEN","KENIA","KELSI","JUDE","JEANICE","ISOBEL","GEORGIANN","GENNY","FELICIDAD","EILENE","DEON","DELOISE","DEEDEE","DANNIE","CONCEPTION","CLORA","CHERILYN","CHANG","CALANDRA","BERRY","ARMANDINA","ANISA","ULA","TIMOTHY","TIERA","THERESSA","STEPHANIA","SIMA","SHYLA","SHONTA","SHERA","SHAQUITA","SHALA","SAMMY","ROSSANA","NOHEMI","NERY","MORIAH","MELITA","MELIDA","MELANI","MARYLYNN","MARISHA","MARIETTE","MALORIE","MADELENE","LUDIVINA","LORIA","LORETTE","LORALEE","LIANNE","LEON","LAVENIA","LAURINDA","LASHON","KIT","KIMI","KEILA","KATELYNN","KAI","JONE","JOANE","JI","JAYNA","JANELLA","JA","HUE","HERTHA","FRANCENE","ELINORE","DESPINA","DELSIE","DEEDRA","CLEMENCIA","CARRY","CAROLIN","CARLOS","BULAH","BRITTANIE","BOK","BLONDELL","BIBI","BEAULAH","BEATA","ANNITA","AGRIPINA","VIRGEN","VALENE","UN","TWANDA","TOMMYE","TOI","TARRA","TARI","TAMMERA","SHAKIA","SADYE","RUTHANNE","ROCHEL","RIVKA","PURA","NENITA","NATISHA","MING","MERRILEE","MELODEE","MARVIS","LUCILLA","LEENA","LAVETA","LARITA","LANIE","KEREN","ILEEN","GEORGEANN","GENNA","GENESIS","FRIDA","EWA","EUFEMIA","EMELY","ELA","EDYTH","DEONNA","DEADRA","DARLENA","CHANELL","CHAN","CATHERN","CASSONDRA","CASSAUNDRA","BERNARDA","BERNA","ARLINDA","ANAMARIA","ALBERT","WESLEY","VERTIE","VALERI","TORRI","TATYANA","STASIA","SHERISE","SHERILL","SEASON","SCOTTIE","SANDA","RUTHE","ROSY","ROBERTO","ROBBI","RANEE","QUYEN","PEARLY","PALMIRA","ONITA","NISHA","NIESHA","NIDA","NEVADA","NAM","MERLYN","MAYOLA","MARYLOUISE","MARYLAND","MARX","MARTH","MARGENE","MADELAINE","LONDA","LEONTINE","LEOMA","LEIA","LAWRENCE","LAURALEE","LANORA","LAKITA","KIYOKO","KETURAH","KATELIN","KAREEN","JONIE","JOHNETTE","JENEE","JEANETT","IZETTA","HIEDI","HEIKE","HASSIE","HAROLD","GIUSEPPINA","GEORGANN","FIDELA","FERNANDE","ELWANDA","ELLAMAE","ELIZ","DUSTI","DOTTY","CYNDY","CORALIE","CELESTA","ARGENTINA","ALVERTA","XENIA","WAVA","VANETTA","TORRIE","TASHINA","TANDY","TAMBRA","TAMA","STEPANIE","SHILA","SHAUNTA","SHARAN","SHANIQUA","SHAE","SETSUKO","SERAFINA","SANDEE","ROSAMARIA","PRISCILA","OLINDA","NADENE","MUOI","MICHELINA","MERCEDEZ","MARYROSE","MARIN","MARCENE","MAO","MAGALI","MAFALDA","LOGAN","LINN","LANNIE","KAYCE","KAROLINE","KAMILAH","KAMALA","JUSTA","JOLINE","JENNINE","JACQUETTA","IRAIDA","GERALD","GEORGEANNA","FRANCHESCA","FAIRY","EMELINE","ELANE","EHTEL","EARLIE","DULCIE","DALENE","CRIS","CLASSIE","CHERE","CHARIS","CAROYLN","CARMINA","CARITA","BRIAN","BETHANIE","AYAKO","ARICA","AN","ALYSA","ALESSANDRA","AKILAH","ADRIEN","ZETTA","YOULANDA","YELENA","YAHAIRA","XUAN","WENDOLYN","VICTOR","TIJUANA","TERRELL","TERINA","TERESIA","SUZI","SUNDAY","SHERELL","SHAVONDA","SHAUNTE","SHARDA","SHAKITA","SENA","RYANN","RUBI","RIVA","REGINIA","REA","RACHAL","PARTHENIA","PAMULA","MONNIE","MONET","MICHAELE","MELIA","MARINE","MALKA","MAISHA","LISANDRA","LEO","LEKISHA","LEAN","LAURENCE","LAKENDRA","KRYSTIN","KORTNEY","KIZZIE","KITTIE","KERA","KENDAL","KEMBERLY","KANISHA","JULENE","JULE","JOSHUA","JOHANNE","JEFFREY","JAMEE","HAN","HALLEY","GIDGET","GALINA","FREDRICKA","FLETA","FATIMAH","EUSEBIA","ELZA","ELEONORE","DORTHEY","DORIA","DONELLA","DINORAH","DELORSE","CLARETHA","CHRISTINIA","CHARLYN","BONG","BELKIS","AZZIE","ANDERA","AIKO","ADENA","YER","YAJAIRA","WAN","VANIA","ULRIKE","TOSHIA","TIFANY","STEFANY","SHIZUE","SHENIKA","SHAWANNA","SHAROLYN","SHARILYN","SHAQUANA","SHANTAY","SEE","ROZANNE","ROSELEE","RICKIE","REMONA","REANNA","RAELENE","QUINN","PHUNG","PETRONILA","NATACHA","NANCEY","MYRL","MIYOKO","MIESHA","MERIDETH","MARVELLA","MARQUITTA","MARHTA","MARCHELLE","LIZETH","LIBBIE","LAHOMA","LADAWN","KINA","KATHELEEN","KATHARYN","KARISA","KALEIGH","JUNIE","JULIEANN","JOHNSIE","JANEAN","JAIMEE","JACKQUELINE","HISAKO","HERMA","HELAINE","GWYNETH","GLENN","GITA","EUSTOLIA","EMELINA","ELIN","EDRIS","DONNETTE","DONNETTA","DIERDRE","DENAE","DARCEL","CLAUDE","CLARISA","CINDERELLA","CHIA","CHARLESETTA","CHARITA","CELSA","CASSY","CASSI","CARLEE","BRUNA","BRITTANEY","BRANDE","BILLI","BAO","ANTONETTA","ANGLA","ANGELYN","ANALISA","ALANE","WENONA","WENDIE","VERONIQUE","VANNESA","TOBIE","TEMPIE","SUMIKO","SULEMA","SPARKLE","SOMER","SHEBA","SHAYNE","SHARICE","SHANEL","SHALON","SAGE","ROY","ROSIO","ROSELIA","RENAY","REMA","REENA","PORSCHE","PING","PEG","OZIE","ORETHA","ORALEE","ODA","NU","NGAN","NAKESHA","MILLY","MARYBELLE","MARLIN","MARIS","MARGRETT","MARAGARET","MANIE","LURLENE","LILLIA","LIESELOTTE","LAVELLE","LASHAUNDA","LAKEESHA","KEITH","KAYCEE","KALYN","JOYA","JOETTE","JENAE","JANIECE","ILLA","GRISEL","GLAYDS","GENEVIE","GALA","FREDDA","FRED","ELMER","ELEONOR","DEBERA","DEANDREA","DAN","CORRINNE","CORDIA","CONTESSA","COLENE","CLEOTILDE","CHARLOTT","CHANTAY","CECILLE","BEATRIS","AZALEE","ARLEAN","ARDATH","ANJELICA","ANJA","ALFREDIA","ALEISHA","ADAM","ZADA","YUONNE","XIAO","WILLODEAN","WHITLEY","VENNIE","VANNA","TYISHA","TOVA","TORIE","TONISHA","TILDA","TIEN","TEMPLE","SIRENA","SHERRIL","SHANTI","SHAN","SENAIDA","SAMELLA","ROBBYN","RENDA","REITA","PHEBE","PAULITA","NOBUKO","NGUYET","NEOMI","MOON","MIKAELA","MELANIA","MAXIMINA","MARG","MAISIE","LYNNA","LILLI","LAYNE","LASHAUN","LAKENYA","LAEL","KIRSTIE","KATHLINE","KASHA","KARLYN","KARIMA","JOVAN","JOSEFINE","JENNELL","JACQUI","JACKELYN","HYO","HIEN","GRAZYNA","FLORRIE","FLORIA","ELEONORA","DWANA","DORLA","DONG","DELMY","DEJA","DEDE","DANN","CRYSTA","CLELIA","CLARIS","CLARENCE","CHIEKO","CHERLYN","CHERELLE","CHARMAIN","CHARA","CAMMY","BEE","ARNETTE","ARDELLE","ANNIKA","AMIEE","AMEE","ALLENA","YVONE","YUKI","YOSHIE","YEVETTE","YAEL","WILLETTA","VONCILE","VENETTA","TULA","TONETTE","TIMIKA","TEMIKA","TELMA","TEISHA","TAREN","TA","STACEE","SHIN","SHAWNTA","SATURNINA","RICARDA","POK","PASTY","ONIE","NUBIA","MORA","MIKE","MARIELLE","MARIELLA","MARIANELA","MARDELL","MANY","LUANNA","LOISE","LISABETH","LINDSY","LILLIANA","LILLIAM","LELAH","LEIGHA","LEANORA","LANG","KRISTEEN","KHALILAH","KEELEY","KANDRA","JUNKO","JOAQUINA","JERLENE","JANI","JAMIKA","JAME","HSIU","HERMILA","GOLDEN","GENEVIVE","EVIA","EUGENA","EMMALINE","ELFREDA","ELENE","DONETTE","DELCIE","DEEANNA","DARCEY","CUC","CLARINDA","CIRA","CHAE","CELINDA","CATHERYN","CATHERIN","CASIMIRA","CARMELIA","CAMELLIA","BREANA","BOBETTE","BERNARDINA","BEBE","BASILIA","ARLYNE","AMAL","ALAYNA","ZONIA","ZENIA","YURIKO","YAEKO","WYNELL","WILLOW","WILLENA","VERNIA","TU","TRAVIS","TORA","TERRILYN","TERICA","TENESHA","TAWNA","TAJUANA","TAINA","STEPHNIE","SONA","SOL","SINA","SHONDRA","SHIZUKO","SHERLENE","SHERICE","SHARIKA","ROSSIE","ROSENA","RORY","RIMA","RIA","RHEBA","RENNA","PETER","NATALYA","NANCEE","MELODI","MEDA","MAXIMA","MATHA","MARKETTA","MARICRUZ","MARCELENE","MALVINA","LUBA","LOUETTA","LEIDA","LECIA","LAURAN","LASHAWNA","LAINE","KHADIJAH","KATERINE","KASI","KALLIE","JULIETTA","JESUSITA","JESTINE","JESSIA","JEREMY","JEFFIE","JANYCE","ISADORA","GEORGIANNE","FIDELIA","EVITA","EURA","EULAH","ESTEFANA","ELSY","ELIZABET","ELADIA","DODIE","DION","DIA","DENISSE","DELORAS","DELILA","DAYSI","DAKOTA","CURTIS","CRYSTLE","CONCHA","COLBY","CLARETTA","CHU","CHRISTIA","CHARLSIE","CHARLENA","CARYLON","BETTYANN","ASLEY","ASHLEA","AMIRA","AI","AGUEDA","AGNUS","YUETTE","VINITA","VICTORINA","TYNISHA","TREENA","TOCCARA","TISH","THOMASENA","TEGAN","SOILA","SHILOH","SHENNA","SHARMAINE","SHANTAE","SHANDI","SEPTEMBER","SARAN","SARAI","SANA","SAMUEL","SALLEY","ROSETTE","ROLANDE","REGINE","OTELIA","OSCAR","OLEVIA","NICHOLLE","NECOLE","NAIDA","MYRTA","MYESHA","MITSUE","MINTA","MERTIE","MARGY","MAHALIA","MADALENE","LOVE","LOURA","LOREAN","LEWIS","LESHA","LEONIDA","LENITA","LAVONE","LASHELL","LASHANDRA","LAMONICA","KIMBRA","KATHERINA","KARRY","KANESHA","JULIO","JONG","JENEVA","JAQUELYN","HWA","GILMA","GHISLAINE","GERTRUDIS","FRANSISCA","FERMINA","ETTIE","ETSUKO","ELLIS","ELLAN","ELIDIA","EDRA","DORETHEA","DOREATHA","DENYSE","DENNY","DEETTA","DAINE","CYRSTAL","CORRIN","CAYLA","CARLITA","CAMILA","BURMA","BULA","BUENA","BLAKE","BARABARA","AVRIL","AUSTIN","ALAINE","ZANA","WILHEMINA","WANETTA","VIRGIL","VI","VERONIKA","VERNON","VERLINE","VASILIKI","TONITA","TISA","TEOFILA","TAYNA","TAUNYA","TANDRA","TAKAKO","SUNNI","SUANNE","SIXTA","SHARELL","SEEMA","RUSSELL","ROSENDA","ROBENA","RAYMONDE","PEI","PAMILA","OZELL","NEIDA","NEELY","MISTIE","MICHA","MERISSA","MAURITA","MARYLN","MARYETTA","MARSHALL","MARCELL","MALENA","MAKEDA","MADDIE","LOVETTA","LOURIE","LORRINE","LORILEE","LESTER","LAURENA","LASHAY","LARRAINE","LAREE","LACRESHA","KRISTLE","KRISHNA","KEVA","KEIRA","KAROLE","JOIE","JINNY","JEANNETTA","JAMA","HEIDY","GILBERTE","GEMA","FAVIOLA","EVELYNN","ENDA","ELLI","ELLENA","DIVINA","DAGNY","COLLENE","CODI","CINDIE","CHASSIDY","CHASIDY","CATRICE","CATHERINA","CASSEY","CAROLL","CARLENA","CANDRA","CALISTA","BRYANNA","BRITTENY","BEULA","BARI","AUDRIE","AUDRIA","ARDELIA","ANNELLE","ANGILA","ALONA","ALLYN","DOUGLAS","ROGER","JONATHAN","RALPH","NICHOLAS","BENJAMIN","BRUCE","HARRY","WAYNE","STEVE","HOWARD","ERNEST","PHILLIP","TODD","CRAIG","ALAN","PHILIP","EARL","DANNY","BRYAN","STANLEY","LEONARD","NATHAN","MANUEL","RODNEY","MARVIN","VINCENT","JEFFERY","JEFF","CHAD","JACOB","ALFRED","BRADLEY","HERBERT","FREDERICK","EDWIN","DON","RICKY","RANDALL","BARRY","BERNARD","LEROY","MARCUS","THEODORE","CLIFFORD","MIGUEL","JIM","TOM","CALVIN","BILL","LLOYD","DEREK","WARREN","DARRELL","JEROME","FLOYD","ALVIN","TIM","GORDON","GREG","JORGE","DUSTIN","PEDRO","DERRICK","ZACHARY","HERMAN","GLEN","HECTOR","RICARDO","RICK","BRENT","RAMON","GILBERT","MARC","REGINALD","RUBEN","NATHANIEL","RAFAEL","EDGAR","MILTON","RAUL","BEN","CHESTER","DUANE","FRANKLIN","BRAD","RON","ROLAND","ARNOLD","HARVEY","JARED","ERIK","DARRYL","NEIL","JAVIER","FERNANDO","CLINTON","TED","MATHEW","TYRONE","DARREN","LANCE","KURT","ALLAN","NELSON","GUY","CLAYTON","HUGH","MAX","DWAYNE","DWIGHT","ARMANDO","FELIX","EVERETT","IAN","WALLACE","KEN","BOB","ALFREDO","ALBERTO","DAVE","IVAN","BYRON","ISAAC","MORRIS","CLIFTON","WILLARD","ROSS","ANDY","SALVADOR","KIRK","SERGIO","SETH","KENT","TERRANCE","EDUARDO","TERRENCE","ENRIQUE","WADE","STUART","FREDRICK","ARTURO","ALEJANDRO","NICK","LUTHER","WENDELL","JEREMIAH","JULIUS","OTIS","TREVOR","OLIVER","LUKE","HOMER","GERARD","DOUG","KENNY","HUBERT","LYLE","MATT","ALFONSO","ORLANDO","REX","CARLTON","ERNESTO","NEAL","PABLO","LORENZO","OMAR","WILBUR","GRANT","HORACE","RODERICK","ABRAHAM","WILLIS","RICKEY","ANDRES","CESAR","JOHNATHAN","MALCOLM","RUDOLPH","DAMON","KELVIN","PRESTON","ALTON","ARCHIE","MARCO","WM","PETE","RANDOLPH","GARRY","GEOFFREY","JONATHON","FELIPE","GERARDO","ED","DOMINIC","DELBERT","COLIN","GUILLERMO","EARNEST","LUCAS","BENNY","SPENCER","RODOLFO","MYRON","EDMUND","GARRETT","SALVATORE","CEDRIC","LOWELL","GREGG","SHERMAN","WILSON","SYLVESTER","ROOSEVELT","ISRAEL","JERMAINE","FORREST","WILBERT","LELAND","SIMON","CLARK","IRVING","BRYANT","OWEN","RUFUS","WOODROW","KRISTOPHER","MACK","LEVI","MARCOS","GUSTAVO","JAKE","LIONEL","GILBERTO","CLINT","NICOLAS","ISMAEL","ORVILLE","ERVIN","DEWEY","AL","WILFRED","JOSH","HUGO","IGNACIO","CALEB","TOMAS","SHELDON","ERICK","STEWART","DOYLE","DARREL","ROGELIO","TERENCE","SANTIAGO","ALONZO","ELIAS","BERT","ELBERT","RAMIRO","CONRAD","NOAH","GRADY","PHIL","CORNELIUS","LAMAR","ROLANDO","CLAY","PERCY","DEXTER","BRADFORD","DARIN","AMOS","MOSES","IRVIN","SAUL","ROMAN","RANDAL","TIMMY","DARRIN","WINSTON","BRENDAN","ABEL","DOMINICK","BOYD","EMILIO","ELIJAH","DOMINGO","EMMETT","MARLON","EMANUEL","JERALD","EDMOND","EMIL","DEWAYNE","WILL","OTTO","TEDDY","REYNALDO","BRET","JESS","TRENT","HUMBERTO","EMMANUEL","STEPHAN","VICENTE","LAMONT","GARLAND","MILES","EFRAIN","HEATH","RODGER","HARLEY","ETHAN","ELDON","ROCKY","PIERRE","JUNIOR","FREDDY","ELI","BRYCE","ANTOINE","STERLING","CHASE","GROVER","ELTON","CLEVELAND","DYLAN","CHUCK","DAMIAN","REUBEN","STAN","AUGUST","LEONARDO","JASPER","RUSSEL","ERWIN","BENITO","HANS","MONTE","BLAINE","ERNIE","CURT","QUENTIN","AGUSTIN","MURRAY","JAMAL","ADOLFO","HARRISON","TYSON","BURTON","BRADY","ELLIOTT","WILFREDO","BART","JARROD","VANCE","DENIS","DAMIEN","JOAQUIN","HARLAN","DESMOND","ELLIOT","DARWIN","GREGORIO","BUDDY","XAVIER","KERMIT","ROSCOE","ESTEBAN","ANTON","SOLOMON","SCOTTY","NORBERT","ELVIN","WILLIAMS","NOLAN","ROD","QUINTON","HAL","BRAIN","ROB","ELWOOD","KENDRICK","DARIUS","MOISES","FIDEL","THADDEUS","CLIFF","MARCEL","JACKSON","RAPHAEL","BRYON","ARMAND","ALVARO","JEFFRY","DANE","JOESPH","THURMAN","NED","RUSTY","MONTY","FABIAN","REGGIE","MASON","GRAHAM","ISAIAH","VAUGHN","GUS","LOYD","DIEGO","ADOLPH","NORRIS","MILLARD","ROCCO","GONZALO","DERICK","RODRIGO","WILEY","RIGOBERTO","ALPHONSO","TY","NOE","VERN","REED","JEFFERSON","ELVIS","BERNARDO","MAURICIO","HIRAM","DONOVAN","BASIL","RILEY","NICKOLAS","MAYNARD","SCOT","VINCE","QUINCY","EDDY","SEBASTIAN","FEDERICO","ULYSSES","HERIBERTO","DONNELL","COLE","DAVIS","GAVIN","EMERY","WARD","ROMEO","JAYSON","DANTE","CLEMENT","COY","MAXWELL","JARVIS","BRUNO","ISSAC","DUDLEY","BROCK","SANFORD","CARMELO","BARNEY","NESTOR","STEFAN","DONNY","ART","LINWOOD","BEAU","WELDON","GALEN","ISIDRO","TRUMAN","DELMAR","JOHNATHON","SILAS","FREDERIC","DICK","IRWIN","MERLIN","CHARLEY","MARCELINO","HARRIS","CARLO","TRENTON","KURTIS","HUNTER","AURELIO","WINFRED","VITO","COLLIN","DENVER","CARTER","LEONEL","EMORY","PASQUALE","MOHAMMAD","MARIANO","DANIAL","LANDON","DIRK","BRANDEN","ADAN","BUFORD","GERMAN","WILMER","EMERSON","ZACHERY","FLETCHER","JACQUES","ERROL","DALTON","MONROE","JOSUE","EDWARDO","BOOKER","WILFORD","SONNY","SHELTON","CARSON","THERON","RAYMUNDO","DAREN","HOUSTON","ROBBY","LINCOLN","GENARO","BENNETT","OCTAVIO","CORNELL","HUNG","ARRON","ANTONY","HERSCHEL","GIOVANNI","GARTH","CYRUS","CYRIL","RONNY","LON","FREEMAN","DUNCAN","KENNITH","CARMINE","ERICH","CHADWICK","WILBURN","RUSS","REID","MYLES","ANDERSON","MORTON","JONAS","FOREST","MITCHEL","MERVIN","ZANE","RICH","JAMEL","LAZARO","ALPHONSE","RANDELL","MAJOR","JARRETT","BROOKS","ABDUL","LUCIANO","SEYMOUR","EUGENIO","MOHAMMED","VALENTIN","CHANCE","ARNULFO","LUCIEN","FERDINAND","THAD","EZRA","ALDO","RUBIN","ROYAL","MITCH","EARLE","ABE","WYATT","MARQUIS","LANNY","KAREEM","JAMAR","BORIS","ISIAH","EMILE","ELMO","ARON","LEOPOLDO","EVERETTE","JOSEF","ELOY","RODRICK","REINALDO","LUCIO","JERROD","WESTON","HERSHEL","BARTON","PARKER","LEMUEL","BURT","JULES","GIL","ELISEO","AHMAD","NIGEL","EFREN","ANTWAN","ALDEN","MARGARITO","COLEMAN","DINO","OSVALDO","LES","DEANDRE","NORMAND","KIETH","TREY","NORBERTO","NAPOLEON","JEROLD","FRITZ","ROSENDO","MILFORD","CHRISTOPER","ALFONZO","LYMAN","JOSIAH","BRANT","WILTON","RICO","JAMAAL","DEWITT","BRENTON","OLIN","FOSTER","FAUSTINO","CLAUDIO","JUDSON","GINO","EDGARDO","ALEC","TANNER","JARRED","DONN","TAD","PRINCE","PORFIRIO","ODIS","LENARD","CHAUNCEY","TOD","MEL","MARCELO","KORY","AUGUSTUS","KEVEN","HILARIO","BUD","SAL","ORVAL","MAURO","ZACHARIAH","OLEN","ANIBAL","MILO","JED","DILLON","AMADO","NEWTON","LENNY","RICHIE","HORACIO","BRICE","MOHAMED","DELMER","DARIO","REYES","MAC","JONAH","JERROLD","ROBT","HANK","RUPERT","ROLLAND","KENTON","DAMION","ANTONE","WALDO","FREDRIC","BRADLY","KIP","BURL","WALKER","TYREE","JEFFEREY","AHMED","WILLY","STANFORD","OREN","NOBLE","MOSHE","MIKEL","ENOCH","BRENDON","QUINTIN","JAMISON","FLORENCIO","DARRICK","TOBIAS","HASSAN","GIUSEPPE","DEMARCUS","CLETUS","TYRELL","LYNDON","KEENAN","WERNER","GERALDO","COLUMBUS","CHET","BERTRAM","MARKUS","HUEY","HILTON","DWAIN","DONTE","TYRON","OMER","ISAIAS","HIPOLITO","FERMIN","ADALBERTO","BO","BARRETT","TEODORO","MCKINLEY","MAXIMO","GARFIELD","RALEIGH","LAWERENCE","ABRAM","RASHAD","KING","EMMITT","DARON","SAMUAL","MIQUEL","EUSEBIO","DOMENIC","DARRON","BUSTER","WILBER","RENATO","JC","HOYT","HAYWOOD","EZEKIEL","CHAS","FLORENTINO","ELROY","CLEMENTE","ARDEN","NEVILLE","EDISON","DESHAWN","NATHANIAL","JORDON","DANILO","CLAUD","SHERWOOD","RAYMON","RAYFORD","CRISTOBAL","AMBROSE","TITUS","HYMAN","FELTON","EZEQUIEL","ERASMO","STANTON","LONNY","LEN","IKE","MILAN","LINO","JAROD","HERB","ANDREAS","WALTON","RHETT","PALMER","DOUGLASS","CORDELL","OSWALDO","ELLSWORTH","VIRGILIO","TONEY","NATHANAEL","DEL","BENEDICT","MOSE","JOHNSON","ISREAL","GARRET","FAUSTO","ASA","ARLEN","ZACK","WARNER","MODESTO","FRANCESCO","MANUAL","GAYLORD","GASTON","FILIBERTO","DEANGELO","MICHALE","GRANVILLE","WES","MALIK","ZACKARY","TUAN","ELDRIDGE","CRISTOPHER","CORTEZ","ANTIONE","MALCOM","LONG","KOREY","JOSPEH","COLTON","WAYLON","VON","HOSEA","SHAD","SANTO","RUDOLF","ROLF","REY","RENALDO","MARCELLUS","LUCIUS","KRISTOFER","BOYCE","BENTON","HAYDEN","HARLAND","ARNOLDO","RUEBEN","LEANDRO","KRAIG","JERRELL","JEROMY","HOBERT","CEDRICK","ARLIE","WINFORD","WALLY","LUIGI","KENETH","JACINTO","GRAIG","FRANKLYN","EDMUNDO","SID","PORTER","LEIF","JERAMY","BUCK","WILLIAN","VINCENZO","SHON","LYNWOOD","JERE","HAI","ELDEN","DORSEY","DARELL","BRODERICK","ALONSO" \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/roman.txt b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/roman.txt new file mode 100644 index 0000000..50651c3 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Project-Euler/roman.txt @@ -0,0 +1,1000 @@ +MMMMDCLXXII +MMDCCCLXXXIII +MMMDLXVIIII +MMMMDXCV +DCCCLXXII +MMCCCVI +MMMCDLXXXVII +MMMMCCXXI +MMMCCXX +MMMMDCCCLXXIII +MMMCCXXXVII +MMCCCLXXXXIX +MDCCCXXIIII +MMCXCVI +CCXCVIII +MMMCCCXXXII +MDCCXXX +MMMDCCCL +MMMMCCLXXXVI +MMDCCCXCVI +MMMDCII +MMMCCXII +MMMMDCCCCI +MMDCCCXCII +MDCXX +CMLXXXVII +MMMXXI +MMMMCCCXIV +MLXXII +MCCLXXVIIII +MMMMCCXXXXI +MMDCCCLXXII +MMMMXXXI +MMMDCCLXXX +MMDCCCLXXIX +MMMMLXXXV +MCXXI +MDCCCXXXVII +MMCCCLXVII +MCDXXXV +CCXXXIII +CMXX +MMMCLXIV +MCCCLXXXVI +DCCCXCVIII +MMMDCCCCXXXIV +CDXVIIII +MMCCXXXV +MDCCCXXXII +MMMMD +MMDCCLXIX +MMMMCCCLXXXXVI +MMDCCXLII +MMMDCCCVIIII +DCCLXXXIIII +MDCCCCXXXII +MMCXXVII +DCCCXXX +CCLXIX +MMMXI +MMMMCMLXXXXVIII +MMMMDLXXXVII +MMMMDCCCLX +MMCCLIV +CMIX +MMDCCCLXXXIIII +CLXXXII +MMCCCCXXXXV +MMMMDLXXXVIIII +MMMDCCCXXI +MMDCCCCLXXVI +MCCCCLXX +MMCDLVIIII +MMMDCCCLIX +MMMMCCCCXIX +MMMDCCCLXXV +XXXI +CDLXXXIII +MMMCXV +MMDCCLXIII +MMDXXX +MMMMCCCLVII +MMMDCI +MMMMCDLXXXIIII +MMMMCCCXVI +CCCLXXXVIII +MMMMCML +MMMMXXIV +MMMCCCCXXX +DCCX +MMMCCLX +MMDXXXIII +CCCLXIII +MMDCCXIII +MMMCCCXLIV +CLXXXXI +CXVI +MMMMCXXXIII +CLXX +DCCCXVIII +MLXVII +DLXXXX +MMDXXI +MMMMDLXXXXVIII +MXXII +LXI +DCCCCXLIII +MMMMDV +MMMMXXXIV +MDCCCLVIII +MMMCCLXXII +MMMMDCCXXXVI +MMMMLXXXIX +MDCCCLXXXI +MMMMDCCCXV +MMMMCCCCXI +MMMMCCCLIII +MDCCCLXXI +MMCCCCXI +MLXV +MMCDLXII +MMMMDXXXXII +MMMMDCCCXL +MMMMCMLVI +CCLXXXIV +MMMDCCLXXXVI +MMCLII +MMMCCCCXV +MMLXXXIII +MMMV +MMMV +DCCLXII +MMDCCCCXVI +MMDCXLVIII +CCLIIII +CCCXXV +MMDCCLXXXVIIII +MMMMDCLXXVIII +MMMMDCCCXCI +MMMMCCCXX +MMCCXLV +MMMDCCCLXIX +MMCCLXIIII +MMMDCCCXLIX +MMMMCCCLXIX +CMLXXXXI +MCMLXXXIX +MMCDLXI +MMDCLXXVIII +MMMMDCCLXI +MCDXXV +DL +CCCLXXII +MXVIIII +MCCCCLXVIII +CIII +MMMDCCLXXIIII +MMMDVIII +MMMMCCCLXXXXVII +MMDXXVII +MMDCCLXXXXV +MMMMCXLVI +MMMDCCLXXXII +MMMDXXXVI +MCXXII +CLI +DCLXXXIX +MMMCLI +MDCLXIII +MMMMDCCXCVII +MMCCCLXXXV +MMMDCXXVIII +MMMCDLX +MMMCMLII +MMMIV +MMMMDCCCLVIII +MMMDLXXXVIII +MCXXIV +MMMMLXXVI +CLXXIX +MMMCCCCXXVIIII +DCCLXXXV +MMMDCCCVI +LI +CLXXXVI +MMMMCCCLXXVI +MCCCLXVI +CCXXXIX +MMDXXXXI +MMDCCCXLI +DCCCLXXXVIII +MMMMDCCCIV +MDCCCCXV +MMCMVI +MMMMCMLXXXXV +MMDCCLVI +MMMMCCXLVIII +DCCCCIIII +MMCCCCIII +MMMDCCLXXXVIIII +MDCCCLXXXXV +DVII +MMMV +DCXXV +MMDCCCXCV +DCVIII +MMCDLXVI +MCXXVIII +MDCCXCVIII +MMDCLX +MMMDCCLXIV +MMCDLXXVII +MMDLXXXIIII +MMMMCCCXXII +MMMDCCCXLIIII +DCCCCLXVII +MMMCLXXXXIII +MCCXV +MMMMDCXI +MMMMDCLXXXXV +MMMCCCLII +MMCMIX +MMDCCXXV +MMDLXXXVI +MMMMDCXXVIIII +DCCCCXXXVIIII +MMCCXXXIIII +MMDCCLXXVIII +MDCCLXVIIII +MMCCLXXXV +MMMMDCCCLXXXVIII +MMCMXCI +MDXLII +MMMMDCCXIV +MMMMLI +DXXXXIII +MMDCCXI +MMMMCCLXXXIII +MMMDCCCLXXIII +MDCLVII +MMCD +MCCCXXVII +MMMMDCCIIII +MMMDCCXLVI +MMMCLXXXVII +MMMCCVIIII +MCCCCLXXIX +DL +DCCCLXXVI +MMDXCI +MMMMDCCCCXXXVI +MMCII +MMMDCCCXXXXV +MMMCDXLV +MMDCXXXXIV +MMD +MDCCCLXXXX +MMDCXLIII +MMCCXXXII +MMDCXXXXVIIII +DCCCLXXI +MDXCVIIII +MMMMCCLXXVIII +MDCLVIIII +MMMCCCLXXXIX +MDCLXXXV +MDLVIII +MMMMCCVII +MMMMDCXIV +MMMCCCLXIIII +MMIIII +MMMMCCCLXXIII +CCIII +MMMCCLV +MMMDXIII +MMMCCCXC +MMMDCCCXXI +MMMMCCCCXXXII +CCCLVI +MMMCCCLXXXVI +MXVIIII +MMMCCCCXIIII +CLXVII +MMMCCLXX +CCCCLXIV +MMXXXXII +MMMMCCLXXXX +MXL +CCXVI +CCCCLVIIII +MMCCCII +MCCCLVIII +MMMMCCCX +MCDLXXXXIV +MDCCCXIII +MMDCCCXL +MMMMCCCXXIII +DXXXIV +CVI +MMMMDCLXXX +DCCCVII +MMCMLXIIII +MMMDCCCXXXIII +DCCC +MDIII +MMCCCLXVI +MMMCCCCLXXI +MMDCCCCXVIII +CCXXXVII +CCCXXV +MDCCCXII +MMMCMV +MMMMCMXV +MMMMDCXCI +DXXI +MMCCXLVIIII +MMMMCMLII +MDLXXX +MMDCLXVI +CXXI +MMMDCCCLIIII +MMMCXXI +MCCIII +MMDCXXXXI +CCXCII +MMMMDXXXV +MMMCCCLXV +MMMMDLXV +MMMCCCCXXXII +MMMCCCVIII +DCCCCLXXXXII +MMCLXIV +MMMMCXI +MLXXXXVII +MMMCDXXXVIII +MDXXII +MLV +MMMMDLXVI +MMMCXII +XXXIII +MMMMDCCCXXVI +MMMLXVIIII +MMMLX +MMMCDLXVII +MDCCCLVII +MMCXXXVII +MDCCCCXXX +MMDCCCLXIII +MMMMDCXLIX +MMMMCMXLVIII +DCCCLXXVIIII +MDCCCLIII +MMMCMLXI +MMMMCCLXI +MMDCCCLIII +MMMDCCCVI +MMDXXXXIX +MMCLXXXXV +MMDXXX +MMMXIII +DCLXXIX +DCCLXII +MMMMDCCLXVIII +MDCCXXXXIII +CCXXXII +MMMMDCXXV +MMMCCCXXVIII +MDCVIII +MMMCLXXXXIIII +CLXXXI +MDCCCCXXXIII +MMMMDCXXX +MMMDCXXIV +MMMCCXXXVII +MCCCXXXXIIII +CXVIII +MMDCCCCIV +MMMMCDLXXV +MMMDLXIV +MDXCIII +MCCLXXXI +MMMDCCCXXIV +MCXLIII +MMMDCCCI +MCCLXXX +CCXV +MMDCCLXXI +MMDLXXXIII +MMMMDCXVII +MMMCMLXV +MCLXVIII +MMMMCCLXXVI +MMMDCCLXVIIII +MMMMDCCCIX +DLXXXXIX +DCCCXXII +MMMMIII +MMMMCCCLXXVI +DCCCXCIII +DXXXI +MXXXIIII +CCXII +MMMDCCLXXXIIII +MMMCXX +MMMCMXXVII +DCCCXXXX +MMCDXXXVIIII +MMMMDCCXVIII +LV +MMMDCCCCVI +MCCCII +MMCMLXVIIII +MDCCXI +MMMMDLXVII +MMCCCCLXI +MMDCCV +MMMCCCXXXIIII +MMMMDI +MMMDCCCXCV +MMDCCLXXXXI +MMMDXXVI +MMMDCCCLVI +MMDCXXX +MCCCVII +MMMMCCCLXII +MMMMXXV +MMCMXXV +MMLVI +MMDXXX +MMMMCVII +MDC +MCCIII +MMMMDCC +MMCCLXXV +MMDCCCXXXXVI +MMMMCCCLXV +CDXIIII +MLXIIII +CCV +MMMCMXXXI +CCCCLXVI +MDXXXII +MMMMCCCLVIII +MMV +MMMCLII +MCMLI +MMDCCXX +MMMMCCCCXXXVI +MCCLXXXI +MMMCMVI +DCCXXX +MMMMCCCLXV +DCCCXI +MMMMDCCCXIV +CCCXXI +MMDLXXV +CCCCLXXXX +MCCCLXXXXII +MMDCIX +DCCXLIIII +DXIV +MMMMCLII +CDLXI +MMMCXXVII +MMMMDCCCCLXIII +MMMDCLIIII +MCCCCXXXXII +MMCCCLX +CCCCLIII +MDCCLXXVI +MCMXXIII +MMMMDLXXVIII +MMDCCCCLX +MMMCCCLXXXX +MMMCDXXVI +MMMDLVIII +CCCLXI +MMMMDCXXII +MMDCCCXXI +MMDCCXIII +MMMMCLXXXVI +MDCCCCXXVI +MDV +MMDCCCCLXXVI +MMMMCCXXXVII +MMMDCCLXXVIIII +MMMCCCCLXVII +DCCXLI +MMCLXXXVIII +MCCXXXVI +MMDCXLVIII +MMMMCXXXII +MMMMDCCLXVI +MMMMCMLI +MMMMCLXV +MMMMDCCCXCIV +MCCLXXVII +LXXVIIII +DCCLII +MMMCCCXCVI +MMMCLV +MMDCCCXXXXVIII +DCCCXV +MXC +MMDCCLXXXXVII +MMMMCML +MMDCCCLXXVIII +DXXI +MCCCXLI +DCLXXXXI +MMCCCLXXXXVIII +MDCCCCLXXVIII +MMMMDXXV +MMMDCXXXVI +MMMCMXCVII +MMXVIIII +MMMDCCLXXIV +MMMCXXV +DXXXVIII +MMMMCLXVI +MDXII +MMCCCLXX +CCLXXI +DXIV +MMMCLIII +DLII +MMMCCCXLIX +MMCCCCXXVI +MMDCXLIII +MXXXXII +CCCLXXXV +MDCLXXVI +MDCXII +MMMCCCLXXXIII +MMDCCCCLXXXII +MMMMCCCLXXXV +MMDCXXI +DCCCXXX +MMMDCCCCLII +MMMDCCXXII +MMMMCDXCVIII +MMMCCLXVIIII +MMXXV +MMMMCDXIX +MMMMCCCX +MMMCCCCLXVI +MMMMDCLXXVIIII +MMMMDCXXXXIV +MMMCMXII +MMMMXXXIII +MMMMDLXXXII +DCCCLIV +MDXVIIII +MMMCLXXXXV +CCCCXX +MMDIX +MMCMLXXXVIII +DCCXLIII +DCCLX +D +MCCCVII +MMMMCCCLXXXIII +MDCCCLXXIIII +MMMDCCCCLXXXVII +MMMMCCCVII +MMMDCCLXXXXVI +CDXXXIV +MCCLXVIII +MMMMDLX +MMMMDXII +MMMMCCCCLIIII +MCMLXXXXIII +MMMMDCCCIII +MMDCLXXXIII +MDCCCXXXXIV +XXXXVII +MMMDCCCXXXII +MMMDCCCXLII +MCXXXV +MDCXXVIIII +MMMCXXXXIIII +MMMMCDXVII +MMMDXXIII +MMMMCCCCLXI +DCLXXXXVIIII +LXXXXI +CXXXIII +MCDX +MCCLVII +MDCXXXXII +MMMCXXIV +MMMMLXXXX +MMDCCCCXLV +MLXXX +MMDCCCCLX +MCDLIII +MMMCCCLXVII +MMMMCCCLXXIV +MMMDCVIII +DCCCCXXIII +MMXCI +MMDCCIV +MMMMDCCCXXXIV +CCCLXXI +MCCLXXXII +MCMIII +CCXXXI +DCCXXXVIII +MMMMDCCXLVIIII +MMMMCMXXXV +DCCCLXXV +DCCXCI +MMMMDVII +MMMMDCCCLXVIIII +CCCXCV +MMMMDCCXX +MCCCCII +MMMCCCXC +MMMCCCII +MMDCCLXXVII +MMDCLIIII +CCXLIII +MMMDCXVIII +MMMCCCIX +MCXV +MMCCXXV +MLXXIIII +MDCCXXVI +MMMCCCXX +MMDLXX +MMCCCCVI +MMDCCXX +MMMMDCCCCXCV +MDCCCXXXII +MMMMDCCCCXXXX +XCIV +MMCCCCLX +MMXVII +MLXXI +MMMDXXVIII +MDCCCCII +MMMCMLVII +MMCLXXXXVIII +MDCCCCLV +MCCCCLXXIIII +MCCCLII +MCDXLVI +MMMMDXVIII +DCCLXXXIX +MMMDCCLXIV +MDCCCCXLIII +CLXXXXV +MMMMCCXXXVI +MMMDCCCXXI +MMMMCDLXXVII +MCDLIII +MMCCXLVI +DCCCLV +MCDLXX +DCLXXVIII +MMDCXXXIX +MMMMDCLX +MMDCCLI +MMCXXXV +MMMCCXII +MMMMCMLXII +MMMMCCV +MCCCCLXIX +MMMMCCIII +CLXVII +MCCCLXXXXIIII +MMMMDCVIII +MMDCCCLXI +MMLXXIX +CMLXIX +MMDCCCXLVIIII +DCLXII +MMMCCCXLVII +MDCCCXXXV +MMMMDCCXCVI +DCXXX +XXVI +MMLXIX +MMCXI +DCXXXVII +MMMMCCCXXXXVIII +MMMMDCLXI +MMMMDCLXXIIII +MMMMVIII +MMMMDCCCLXII +MDCXCI +MMCCCXXIIII +CCCCXXXXV +MMDCCCXXI +MCVI +MMDCCLXVIII +MMMMCXL +MLXVIII +CMXXVII +CCCLV +MDCCLXXXIX +MMMCCCCLXV +MMDCCLXII +MDLXVI +MMMCCCXVIII +MMMMCCLXXXI +MMCXXVII +MMDCCCLXVIII +MMMCXCII +MMMMDCLVIII +MMMMDCCCXXXXII +MMDCCCCLXXXXVI +MDCCXL +MDCCLVII +MMMMDCCCLXXXVI +DCCXXXIII +MMMMDCCCCLXXXV +MMCCXXXXVIII +MMMCCLXXVIII +MMMDCLXXVIII +DCCCI +MMMMLXXXXVIIII +MMMCCCCLXXII +MMCLXXXVII +CCLXVI +MCDXLIII +MMCXXVIII +MDXIV +CCCXCVIII +CLXXVIII +MMCXXXXVIIII +MMMDCLXXXIV +CMLVIII +MCDLIX +MMMMDCCCXXXII +MMMMDCXXXIIII +MDCXXI +MMMDCXLV +MCLXXVIII +MCDXXII +IV +MCDLXXXXIII +MMMMDCCLXV +CCLI +MMMMDCCCXXXVIII +DCLXII +MCCCLXVII +MMMMDCCCXXXVI +MMDCCXLI +MLXI +MMMCDLXVIII +MCCCCXCIII +XXXIII +MMMDCLXIII +MMMMDCL +DCCCXXXXIIII +MMDLVII +DXXXVII +MCCCCXXIIII +MCVII +MMMMDCCXL +MMMMCXXXXIIII +MCCCCXXIV +MMCLXVIII +MMXCIII +MDCCLXXX +MCCCLIIII +MMDCLXXI +MXI +MCMLIV +MMMCCIIII +DCCLXXXVIIII +MDCLIV +MMMDCXIX +CMLXXXI +DCCLXXXVII +XXV +MMMXXXVI +MDVIIII +CLXIII +MMMCDLVIIII +MMCCCCVII +MMMLXX +MXXXXII +MMMMCCCLXVIII +MMDCCCXXVIII +MMMMDCXXXXI +MMMMDCCCXXXXV +MMMXV +MMMMCCXVIIII +MMDCCXIIII +MMMXXVII +MDCCLVIIII +MMCXXIIII +MCCCLXXIV +DCLVIII +MMMLVII +MMMCXLV +MMXCVII +MMMCCCLXXXVII +MMMMCCXXII +DXII +MMMDLV +MCCCLXXVIII +MMMCLIIII +MMMMCLXXXX +MMMCLXXXIIII +MDCXXIII +MMMMCCXVI +MMMMDLXXXIII +MMMDXXXXIII +MMMMCCCCLV +MMMDLXXXI +MMMCCLXXVI +MMMMXX +MMMMDLVI +MCCCCLXXX +MMMXXII +MMXXII +MMDCCCCXXXI +MMMDXXV +MMMDCLXXXVIIII +MMMDLXXXXVII +MDLXIIII +CMXC +MMMXXXVIII +MDLXXXVIII +MCCCLXXVI +MMCDLIX +MMDCCCXVIII +MDCCCXXXXVI +MMMMCMIV +MMMMDCIIII +MMCCXXXV +XXXXVI +MMMMCCXVII +MMCCXXIV +MCMLVIIII +MLXXXIX +MMMMLXXXIX +CLXXXXIX +MMMDCCCCLVIII +MMMMCCLXXIII +MCCCC +DCCCLIX +MMMCCCLXXXII +MMMCCLXVIIII +MCLXXXV +CDLXXXVII +DCVI +MMX +MMCCXIII +MMMMDCXX +MMMMXXVIII +DCCCLXII +MMMMCCCXLIII +MMMMCLXV +DXCI +MMMMCLXXX +MMMDCCXXXXI +MMMMXXXXVI +DCLX +MMMCCCXI +MCCLXXX +MMCDLXXII +DCCLXXI +MMMCCCXXXVI +MCCCCLXXXVIIII +CDLVIII +DCCLVI +MMMMDCXXXVIII +MMCCCLXXXIII +MMMMDCCLXXV +MMMXXXVI +CCCLXXXXIX +CV +CCCCXIII +CCCCXVI +MDCCCLXXXIIII +MMDCCLXXXII +MMMMCCCCLXXXI +MXXV +MMCCCLXXVIIII +MMMCCXII +MMMMCCXXXIII +MMCCCLXXXVI +MMMDCCCLVIIII +MCCXXXVII +MDCLXXV +XXXV +MMDLI +MMMCCXXX +MMMMCXXXXV +CCCCLIX +MMMMDCCCLXXIII +MMCCCXVII +DCCCXVI +MMMCCCXXXXV +MDCCCCXCV +CLXXXI +MMMMDCCLXX +MMMDCCCIII +MMCLXXVII +MMMDCCXXIX +MMDCCCXCIIII +MMMCDXXIIII +MMMMXXVIII +MMMMDCCCCLXVIII +MDCCCXX +MMMMCDXXI +MMMMDLXXXIX +CCXVI +MDVIII +MMCCLXXI +MMMDCCCLXXI +MMMCCCLXXVI +MMCCLXI +MMMMDCCCXXXIV +DLXXXVI +MMMMDXXXII +MMMXXIIII +MMMMCDIV +MMMMCCCXLVIII +MMMMCXXXVIII +MMMCCCLXVI +MDCCXVIII +MMCXX +CCCLIX +MMMMDCCLXXII +MDCCCLXXV +MMMMDCCCXXIV +DCCCXXXXVIII +MMMDCCCCXXXVIIII +MMMMCCXXXV +MDCLXXXIII +MMCCLXXXIV +MCLXXXXIIII +DXXXXIII +MCCCXXXXVIII +MMCLXXIX +MMMMCCLXIV +MXXII +MMMCXIX +MDCXXXVII +MMDCCVI +MCLXXXXVIII +MMMCXVI +MCCCLX +MMMCDX +CCLXVIIII +MMMCCLX +MCXXVIII +LXXXII +MCCCCLXXXI +MMMI +MMMCCCLXIV +MMMCCCXXVIIII +CXXXVIII +MMCCCXX +MMMCCXXVIIII +MCCLXVI +MMMCCCCXXXXVI +MMDCCXCIX +MCMLXXI +MMCCLXVIII +CDLXXXXIII +MMMMDCCXXII +MMMMDCCLXXXVII +MMMDCCLIV +MMCCLXIII +MDXXXVII +DCCXXXIIII +MCII +MMMDCCCLXXI +MMMLXXIII +MDCCCLIII +MMXXXVIII +MDCCXVIIII +MDCCCCXXXVII +MMCCCXVI +MCMXXII +MMMCCCLVIII +MMMMDCCCXX +MCXXIII +MMMDLXI +MMMMDXXII +MDCCCX +MMDXCVIIII +MMMDCCCCVIII +MMMMDCCCCXXXXVI +MMDCCCXXXV +MMCXCIV +MCMLXXXXIII +MMMCCCLXXVI +MMMMDCLXXXV +CMLXIX +DCXCII +MMXXVIII +MMMMCCCXXX +XXXXVIIII \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/.gitignore b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/.gitignore new file mode 100644 index 0000000..51cbe85 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/.gitignore @@ -0,0 +1,54 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +# Sphinx documentation +docs/_build/ + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/2013/tco2013_round3_3b_div1.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/2013/tco2013_round3_3b_div1.py new file mode 100644 index 0000000..491ab8f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/2013/tco2013_round3_3b_div1.py @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +# mari von steinkirch @2013 +# steinkirch at gmail + + + +def findToneDiff(tones): + tonesDiff = [] + n = len(tones) + for i, tone in enumerate(tones): + for j in range(i+1, len(tones)): + sum_here = abs(tone - tones[j]) + tonesDiff.append([sum_here, i, j]) + return sorted(tonesDiff) + +def findAllPossible(duration, tones, T): + tonesDiff = findToneDiff(tones) + sumsTone1 = [(song, i) for i, song in enumerate(duration) if song <= T] + sumsTone2 = [] + for song in tonesDiff: + sum_here = song[0] + duration[song[1]] + duration[song[2]] + if sum_here <= T: + sumsTone2.append((sum_here, song[1], song[2], 2)) + return sumsTone1, sumsTone2 + + +def findAllPossibleNext(sumsTone, T, n_music): + sumsTone2 = [] + for i, song1 in enumerate(sumsTone): + index1 = song1[1] + for j in range(i+1, len(sumsTone)): + song2 = sumsTone[j] + index2 = song2[1] + if index1 == index2: + sum_here = song1[0] + song2[0] + if sum_here < T: + sumsTone2.append((sum_here, song2[1], song2[2], n_music)) + + + return sumsTone2 + + +def maxSongs(duration, tones, T): + + if min(duration) >= T: + return 0 + + sumsTone1, sumsTone = findAllPossible(duration, tones, T) + if not sumsTone: + return 1 + + while sumsTone: + n_music = sumsTone[0][3]+1 + sumsTone = findAllPossibleNext(sumsTone, T, n_music) + if not sumsTone: + return n_music + + + +def tests_250(): + print(maxSongs([3, 5, 4, 11], [2, 1, 3, 1], 17)) #3 + print(maxSongs([9, 11, 13, 17], [2, 1, 3, 4], 20)) #1 + print(maxSongs([100, 200, 300], [1,2,3], 99)) #0 + print(maxSongs([87,21,20,73,97,57,12,80,86,97,98,85,41,12,89,15,41,17,68,37,21,1,9,65,4,67,38,91,46,82,7,98,21,70,99,41,21,65,11,1,8,12,77,62,52,69,56,33,98,97], [88,27,89,2,96,32,4,93,89,50,58,70,15,48,31,2,27,20,31,3,23,86,69,12,59,61,85,67,77,34,29,3,75,42,50,37,56,45,51,68,89,17,4,47,9,14,29,59,43,3], 212)) + + + +if __name__ == '__main__': + tests_250() + diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/README.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/README.md new file mode 100644 index 0000000..3cd5e6e --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/Top-Coder/README.md @@ -0,0 +1,13 @@ +### šŸ¬ [Top Coder](Solutions) for Fun or Profit + + +---- + + +## License + +When making a reference to my work, please use my [website](http://bt3gl.github.io/index.html). + +Creative Commons License
+ +This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/.gitignore b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/.gitignore new file mode 100644 index 0000000..1058c2d --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/.gitignore @@ -0,0 +1,30 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.ko +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/LICENSE b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/LICENSE new file mode 100644 index 0000000..9cecc1d --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/.DS_Store b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/.DS_Store new file mode 100644 index 0000000..5604fe1 Binary files /dev/null and b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/.DS_Store differ diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/Makefile b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/Makefile new file mode 100644 index 0000000..c21f1d8 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/Makefile @@ -0,0 +1,9 @@ +obj-m += eudyptula_1.o + KERNEL_VER ?= $(shell uname -r) + KERNEL_PATH ?= /lib/modules/$(KERNEL_VER)/build + +all: + make -C $(KERNEL_PATH) M=$(PWD) modules + +clean: + make -C $(KERNEL_PATH) M=$(PWD) clean diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/eudyptula_1.c b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/eudyptula_1.c new file mode 100644 index 0000000..30e1733 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/eudyptula_1.c @@ -0,0 +1,22 @@ +/* + * Eudyptula #1 + */ + +#include +#include +#include + +int init_module(void) +{ + printk(KERN_DEBUG "Ola Mundo!\n"); + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_DEBUG "Unloading exer 1! Goodbye!!!\n"); +} + + +MODULE_LICENSE("GLP"); +MODULE_AUTHOR("7e1cf379bd3d"); diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/useful_commands b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/useful_commands new file mode 100644 index 0000000..a95bbf2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_01/useful_commands @@ -0,0 +1,5 @@ +make +sudo insmod ./eudyptula_1.ko +cat /proc/modules | grep eudyptula +lsmod | grep eudyptula +sudo rmmod eudyptula_1 diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/Screen Shot 2017-04-24 at 11.13.33 AM.png b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/Screen Shot 2017-04-24 at 11.13.33 AM.png new file mode 100644 index 0000000..3956f5f Binary files /dev/null and b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/Screen Shot 2017-04-24 at 11.13.33 AM.png differ diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/config b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/config new file mode 100755 index 0000000..5d9ff98 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/config @@ -0,0 +1,5261 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/x86 4.11.0-rc8 Kernel Configuration +# +CONFIG_64BIT=y +CONFIG_X86_64=y +CONFIG_X86=y +CONFIG_INSTRUCTION_DECODER=y +CONFIG_OUTPUT_FORMAT="elf64-x86-64" +CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig" +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_MMU=y +CONFIG_ARCH_MMAP_RND_BITS_MIN=28 +CONFIG_ARCH_MMAP_RND_BITS_MAX=32 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y +CONFIG_GENERIC_HWEIGHT=y +CONFIG_ARCH_MAY_HAVE_PC_FDC=y +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_ARCH_HAS_CPU_RELAX=y +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y +CONFIG_HAVE_SETUP_PER_CPU_AREA=y +CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y +CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ZONE_DMA32=y +CONFIG_AUDIT_ARCH=y +CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y +CONFIG_HAVE_INTEL_TXT=y +CONFIG_X86_64_SMP=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_PGTABLE_LEVELS=4 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +CONFIG_IRQ_WORK=y +CONFIG_BUILDTIME_EXTABLE_SORT=y +CONFIG_THREAD_INFO_IN_TASK=y + +# +# General setup +# +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_CROSS_COMPILE="" +# CONFIG_COMPILE_TEST is not set +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y +CONFIG_HAVE_KERNEL_GZIP=y +CONFIG_HAVE_KERNEL_BZIP2=y +CONFIG_HAVE_KERNEL_LZMA=y +CONFIG_HAVE_KERNEL_XZ=y +CONFIG_HAVE_KERNEL_LZO=y +CONFIG_HAVE_KERNEL_LZ4=y +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +# CONFIG_KERNEL_XZ is not set +# CONFIG_KERNEL_LZO is not set +# CONFIG_KERNEL_LZ4 is not set +CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +CONFIG_POSIX_MQUEUE_SYSCTL=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_FHANDLE=y +CONFIG_USELIB=y +CONFIG_AUDIT=y +CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_AUDITSYSCALL=y +CONFIG_AUDIT_WATCH=y +CONFIG_AUDIT_TREE=y + +# +# IRQ subsystem +# +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_PENDING_IRQ=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +# CONFIG_IRQ_DOMAIN_DEBUG is not set +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_SPARSE_IRQ=y +CONFIG_CLOCKSOURCE_WATCHDOG=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y +CONFIG_GENERIC_CMOS_UPDATE=y + +# +# Timers subsystem +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ_COMMON=y +# CONFIG_HZ_PERIODIC is not set +CONFIG_NO_HZ_IDLE=y +# CONFIG_NO_HZ_FULL is not set +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y + +# +# CPU/Task time and stats accounting +# +CONFIG_TICK_CPU_ACCOUNTING=y +# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set +# CONFIG_IRQ_TIME_ACCOUNTING is not set +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_BSD_PROCESS_ACCT_V3=y +CONFIG_TASKSTATS=y +CONFIG_TASK_DELAY_ACCT=y +CONFIG_TASK_XACCT=y +CONFIG_TASK_IO_ACCOUNTING=y + +# +# RCU Subsystem +# +CONFIG_TREE_RCU=y +# CONFIG_RCU_EXPERT is not set +CONFIG_SRCU=y +# CONFIG_TASKS_RCU is not set +CONFIG_RCU_STALL_COMMON=y +# CONFIG_TREE_RCU_TRACE is not set +CONFIG_BUILD_BIN2C=y +CONFIG_IKCONFIG=m +# CONFIG_IKCONFIG_PROC is not set +CONFIG_LOG_BUF_SHIFT=18 +CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13 +CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y +CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y +CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y +CONFIG_ARCH_SUPPORTS_INT128=y +CONFIG_NUMA_BALANCING=y +CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y +CONFIG_CGROUPS=y +CONFIG_PAGE_COUNTER=y +CONFIG_MEMCG=y +CONFIG_MEMCG_SWAP=y +# CONFIG_MEMCG_SWAP_ENABLED is not set +CONFIG_BLK_CGROUP=y +# CONFIG_DEBUG_BLK_CGROUP is not set +CONFIG_CGROUP_WRITEBACK=y +CONFIG_CGROUP_SCHED=y +CONFIG_FAIR_GROUP_SCHED=y +CONFIG_CFS_BANDWIDTH=y +# CONFIG_RT_GROUP_SCHED is not set +CONFIG_CGROUP_PIDS=y +# CONFIG_CGROUP_RDMA is not set +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_HUGETLB=y +CONFIG_CPUSETS=y +CONFIG_PROC_PID_CPUSET=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_PERF=y +# CONFIG_CGROUP_BPF is not set +# CONFIG_CGROUP_DEBUG is not set +CONFIG_SOCK_CGROUP_DATA=y +CONFIG_CHECKPOINT_RESTORE=y +CONFIG_NAMESPACES=y +CONFIG_UTS_NS=y +CONFIG_IPC_NS=y +CONFIG_USER_NS=y +CONFIG_PID_NS=y +CONFIG_NET_NS=y +CONFIG_SCHED_AUTOGROUP=y +# CONFIG_SYSFS_DEPRECATED is not set +CONFIG_RELAY=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_RD_GZIP=y +CONFIG_RD_BZIP2=y +CONFIG_RD_LZMA=y +CONFIG_RD_XZ=y +CONFIG_RD_LZO=y +CONFIG_RD_LZ4=y +CONFIG_INITRAMFS_COMPRESSION=".gz" +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +CONFIG_HAVE_UID16=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_HAVE_PCSPKR_PLATFORM=y +CONFIG_BPF=y +CONFIG_EXPERT=y +CONFIG_UID16=y +CONFIG_MULTIUSER=y +CONFIG_SGETMASK_SYSCALL=y +CONFIG_SYSFS_SYSCALL=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_POSIX_TIMERS=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_ALL=y +CONFIG_KALLSYMS_ABSOLUTE_PERCPU=y +CONFIG_KALLSYMS_BASE_RELATIVE=y +CONFIG_PRINTK=y +CONFIG_PRINTK_NMI=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_PCSPKR_PLATFORM=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_BPF_SYSCALL=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_ADVISE_SYSCALLS=y +CONFIG_USERFAULTFD=y +CONFIG_PCI_QUIRKS=y +CONFIG_MEMBARRIER=y +# CONFIG_EMBEDDED is not set +CONFIG_HAVE_PERF_EVENTS=y +# CONFIG_PC104 is not set + +# +# Kernel Performance Events And Counters +# +CONFIG_PERF_EVENTS=y +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +# CONFIG_SLUB_MEMCG_SYSFS_ON is not set +# CONFIG_COMPAT_BRK is not set +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +CONFIG_SLAB_FREELIST_RANDOM=y +CONFIG_SLUB_CPU_PARTIAL=y +CONFIG_SYSTEM_DATA_VERIFICATION=y +CONFIG_PROFILING=y +CONFIG_TRACEPOINTS=y +CONFIG_KEXEC_CORE=y +# CONFIG_OPROFILE is not set +CONFIG_HAVE_OPROFILE=y +CONFIG_OPROFILE_NMI_TIMER=y +CONFIG_KPROBES=y +CONFIG_JUMP_LABEL=y +# CONFIG_STATIC_KEYS_SELFTEST is not set +CONFIG_OPTPROBES=y +CONFIG_KPROBES_ON_FTRACE=y +# CONFIG_UPROBES is not set +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_KRETPROBES=y +CONFIG_HAVE_IOREMAP_PROT=y +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_KPROBES_ON_FTRACE=y +CONFIG_HAVE_NMI=y +CONFIG_HAVE_ARCH_TRACEHOOK=y +CONFIG_HAVE_DMA_CONTIGUOUS=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_CLK=y +CONFIG_HAVE_DMA_API_DEBUG=y +CONFIG_HAVE_HW_BREAKPOINT=y +CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y +CONFIG_HAVE_USER_RETURN_NOTIFIER=y +CONFIG_HAVE_PERF_EVENTS_NMI=y +CONFIG_HAVE_PERF_REGS=y +CONFIG_HAVE_PERF_USER_STACK_DUMP=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y +CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y +CONFIG_HAVE_CMPXCHG_LOCAL=y +CONFIG_HAVE_CMPXCHG_DOUBLE=y +CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y +CONFIG_ARCH_WANT_OLD_COMPAT_IPC=y +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_SECCOMP_FILTER=y +CONFIG_HAVE_GCC_PLUGINS=y +# CONFIG_GCC_PLUGINS is not set +CONFIG_HAVE_CC_STACKPROTECTOR=y +CONFIG_CC_STACKPROTECTOR=y +# CONFIG_CC_STACKPROTECTOR_NONE is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y +CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES=y +CONFIG_HAVE_CONTEXT_TRACKING=y +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y +CONFIG_HAVE_ARCH_HUGE_VMAP=y +CONFIG_HAVE_ARCH_SOFT_DIRTY=y +CONFIG_MODULES_USE_ELF_RELA=y +CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_HAVE_ARCH_MMAP_RND_BITS=y +CONFIG_HAVE_EXIT_THREAD=y +CONFIG_ARCH_MMAP_RND_BITS=28 +CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y +CONFIG_ARCH_MMAP_RND_COMPAT_BITS=8 +CONFIG_HAVE_COPY_THREAD_TLS=y +CONFIG_HAVE_STACK_VALIDATION=y +# CONFIG_HAVE_ARCH_HASH is not set +CONFIG_ISA_BUS_API=y +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_COMPAT_OLD_SIGACTION=y +# CONFIG_CPU_NO_EFFICIENT_FFS is not set +CONFIG_HAVE_ARCH_VMAP_STACK=y +CONFIG_VMAP_STACK=y +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX is not set +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_STRICT_MODULE_RWX=y + +# +# GCOV-based kernel profiling +# +# CONFIG_GCOV_KERNEL is not set +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_MODVERSIONS=y +CONFIG_MODULE_SRCVERSION_ALL=y +CONFIG_MODULE_SIG=y +# CONFIG_MODULE_SIG_FORCE is not set +CONFIG_MODULE_SIG_ALL=y +# CONFIG_MODULE_SIG_SHA1 is not set +# CONFIG_MODULE_SIG_SHA224 is not set +# CONFIG_MODULE_SIG_SHA256 is not set +# CONFIG_MODULE_SIG_SHA384 is not set +CONFIG_MODULE_SIG_SHA512=y +CONFIG_MODULE_SIG_HASH="sha512" +# CONFIG_MODULE_COMPRESS is not set +CONFIG_MODULES_TREE_LOOKUP=y +CONFIG_BLOCK=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_BSGLIB=y +CONFIG_BLK_DEV_INTEGRITY=y +# CONFIG_BLK_DEV_ZONED is not set +CONFIG_BLK_DEV_THROTTLING=y +CONFIG_BLK_CMDLINE_PARSER=y +# CONFIG_BLK_WBT is not set +CONFIG_BLK_DEBUG_FS=y +# CONFIG_BLK_SED_OPAL is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +CONFIG_AIX_PARTITION=y +CONFIG_OSF_PARTITION=y +CONFIG_AMIGA_PARTITION=y +CONFIG_ATARI_PARTITION=y +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +CONFIG_LDM_PARTITION=y +# CONFIG_LDM_DEBUG is not set +CONFIG_SGI_PARTITION=y +CONFIG_ULTRIX_PARTITION=y +CONFIG_SUN_PARTITION=y +CONFIG_KARMA_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_SYSV68_PARTITION=y +CONFIG_CMDLINE_PARTITION=y +CONFIG_BLOCK_COMPAT=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_MQ_VIRTIO=y + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +CONFIG_CFQ_GROUP_IOSCHED=y +CONFIG_DEFAULT_DEADLINE=y +# CONFIG_DEFAULT_CFQ is not set +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="deadline" +CONFIG_MQ_IOSCHED_DEADLINE=y +CONFIG_ASN1=y +CONFIG_INLINE_SPIN_UNLOCK_IRQ=y +CONFIG_INLINE_READ_UNLOCK=y +CONFIG_INLINE_READ_UNLOCK_IRQ=y +CONFIG_INLINE_WRITE_UNLOCK=y +CONFIG_INLINE_WRITE_UNLOCK_IRQ=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y +CONFIG_QUEUED_SPINLOCKS=y +CONFIG_ARCH_USE_QUEUED_RWLOCKS=y +CONFIG_QUEUED_RWLOCKS=y +CONFIG_FREEZER=y + +# +# Processor type and features +# +CONFIG_ZONE_DMA=y +CONFIG_SMP=y +CONFIG_X86_FEATURE_NAMES=y +CONFIG_X86_FAST_FEATURE_TESTS=y +CONFIG_X86_X2APIC=y +CONFIG_X86_MPPARSE=y +# CONFIG_GOLDFISH is not set +# CONFIG_INTEL_RDT_A is not set +CONFIG_X86_EXTENDED_PLATFORM=y +CONFIG_X86_NUMACHIP=y +# CONFIG_X86_VSMP is not set +# CONFIG_X86_UV is not set +# CONFIG_X86_GOLDFISH is not set +# CONFIG_X86_INTEL_MID is not set +CONFIG_X86_INTEL_LPSS=y +CONFIG_X86_AMD_PLATFORM_DEVICE=y +CONFIG_IOSF_MBI=y +CONFIG_IOSF_MBI_DEBUG=y +CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y +CONFIG_SCHED_OMIT_FRAME_POINTER=y +CONFIG_HYPERVISOR_GUEST=y +CONFIG_PARAVIRT=y +# CONFIG_PARAVIRT_DEBUG is not set +CONFIG_PARAVIRT_SPINLOCKS=y +# CONFIG_QUEUED_LOCK_STAT is not set +CONFIG_XEN=y +CONFIG_XEN_DOM0=y +CONFIG_XEN_PVHVM=y +CONFIG_XEN_512GB=y +CONFIG_XEN_SAVE_RESTORE=y +# CONFIG_XEN_DEBUG_FS is not set +CONFIG_XEN_PVH=y +CONFIG_KVM_GUEST=y +CONFIG_KVM_DEBUG_FS=y +# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set +CONFIG_PARAVIRT_CLOCK=y +CONFIG_NO_BOOTMEM=y +# CONFIG_MK8 is not set +# CONFIG_MPSC is not set +# CONFIG_MCORE2 is not set +# CONFIG_MATOM is not set +CONFIG_GENERIC_CPU=y +CONFIG_X86_INTERNODE_CACHE_SHIFT=6 +CONFIG_X86_L1_CACHE_SHIFT=6 +CONFIG_X86_TSC=y +CONFIG_X86_CMPXCHG64=y +CONFIG_X86_CMOV=y +CONFIG_X86_MINIMUM_CPU_FAMILY=64 +CONFIG_X86_DEBUGCTLMSR=y +CONFIG_PROCESSOR_SELECT=y +CONFIG_CPU_SUP_INTEL=y +CONFIG_CPU_SUP_AMD=y +CONFIG_CPU_SUP_CENTAUR=y +CONFIG_HPET_TIMER=y +CONFIG_HPET_EMULATE_RTC=y +CONFIG_DMI=y +CONFIG_GART_IOMMU=y +CONFIG_CALGARY_IOMMU=y +CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT=y +CONFIG_SWIOTLB=y +CONFIG_IOMMU_HELPER=y +# CONFIG_MAXSMP is not set +CONFIG_NR_CPUS=512 +CONFIG_SCHED_SMT=y +CONFIG_SCHED_MC=y +CONFIG_SCHED_MC_PRIO=y +# CONFIG_PREEMPT_NONE is not set +CONFIG_PREEMPT_VOLUNTARY=y +# CONFIG_PREEMPT is not set +CONFIG_X86_LOCAL_APIC=y +CONFIG_X86_IO_APIC=y +CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y +CONFIG_X86_MCE=y +CONFIG_X86_MCE_INTEL=y +CONFIG_X86_MCE_AMD=y +CONFIG_X86_MCE_THRESHOLD=y +# CONFIG_X86_MCE_INJECT is not set +CONFIG_X86_THERMAL_VECTOR=y + +# +# Performance monitoring +# +CONFIG_PERF_EVENTS_INTEL_UNCORE=y +CONFIG_PERF_EVENTS_INTEL_RAPL=m +# CONFIG_PERF_EVENTS_INTEL_CSTATE is not set +# CONFIG_PERF_EVENTS_AMD_POWER is not set +# CONFIG_VM86 is not set +CONFIG_X86_16BIT=y +CONFIG_X86_ESPFIX64=y +CONFIG_X86_VSYSCALL_EMULATION=y +# CONFIG_I8K is not set +CONFIG_MICROCODE=y +CONFIG_MICROCODE_INTEL=y +CONFIG_MICROCODE_AMD=y +CONFIG_MICROCODE_OLD_INTERFACE=y +# CONFIG_X86_MSR is not set +# CONFIG_X86_CPUID is not set +CONFIG_ARCH_PHYS_ADDR_T_64BIT=y +CONFIG_ARCH_DMA_ADDR_T_64BIT=y +CONFIG_X86_DIRECT_GBPAGES=y +CONFIG_NUMA=y +CONFIG_AMD_NUMA=y +CONFIG_X86_64_ACPI_NUMA=y +CONFIG_NODES_SPAN_OTHER_NODES=y +# CONFIG_NUMA_EMU is not set +CONFIG_NODES_SHIFT=6 +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_SPARSEMEM_DEFAULT=y +CONFIG_ARCH_SELECT_MEMORY_MODEL=y +CONFIG_ARCH_MEMORY_PROBE=y +CONFIG_ARCH_PROC_KCORE_TEXT=y +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_SPARSEMEM_MANUAL=y +CONFIG_SPARSEMEM=y +CONFIG_NEED_MULTIPLE_NODES=y +CONFIG_HAVE_MEMORY_PRESENT=y +CONFIG_SPARSEMEM_EXTREME=y +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y +CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER=y +CONFIG_SPARSEMEM_VMEMMAP=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MEMBLOCK_NODE_MAP=y +CONFIG_ARCH_DISCARD_MEMBLOCK=y +CONFIG_MEMORY_ISOLATION=y +CONFIG_MOVABLE_NODE=y +CONFIG_HAVE_BOOTMEM_INFO_NODE=y +CONFIG_MEMORY_HOTPLUG=y +CONFIG_MEMORY_HOTPLUG_SPARSE=y +CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y +CONFIG_MEMORY_HOTREMOVE=y +CONFIG_SPLIT_PTLOCK_CPUS=4 +CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y +CONFIG_MEMORY_BALLOON=y +CONFIG_BALLOON_COMPACTION=y +CONFIG_COMPACTION=y +CONFIG_MIGRATION=y +CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION=y +CONFIG_PHYS_ADDR_T_64BIT=y +CONFIG_BOUNCE=y +CONFIG_VIRT_TO_BUS=y +CONFIG_MMU_NOTIFIER=y +CONFIG_KSM=y +CONFIG_DEFAULT_MMAP_MIN_ADDR=65536 +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y +CONFIG_MEMORY_FAILURE=y +# CONFIG_HWPOISON_INJECT is not set +CONFIG_TRANSPARENT_HUGEPAGE=y +CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y +# CONFIG_TRANSPARENT_HUGEPAGE_MADVISE is not set +CONFIG_TRANSPARENT_HUGE_PAGECACHE=y +CONFIG_CLEANCACHE=y +CONFIG_FRONTSWAP=y +CONFIG_CMA=y +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_AREAS=7 +CONFIG_MEM_SOFT_DIRTY=y +CONFIG_ZSWAP=y +CONFIG_ZPOOL=y +CONFIG_ZBUD=y +# CONFIG_Z3FOLD is not set +CONFIG_ZSMALLOC=y +CONFIG_PGTABLE_MAPPING=y +# CONFIG_ZSMALLOC_STAT is not set +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT=y +# CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set +CONFIG_IDLE_PAGE_TRACKING=y +CONFIG_ZONE_DEVICE=y +CONFIG_FRAME_VECTOR=y +CONFIG_ARCH_USES_HIGH_VMA_FLAGS=y +CONFIG_ARCH_HAS_PKEYS=y +CONFIG_X86_PMEM_LEGACY_DEVICE=y +CONFIG_X86_PMEM_LEGACY=y +CONFIG_X86_CHECK_BIOS_CORRUPTION=y +CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK=y +CONFIG_X86_RESERVE_LOW=64 +CONFIG_MTRR=y +CONFIG_MTRR_SANITIZER=y +CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=1 +CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1 +CONFIG_X86_PAT=y +CONFIG_ARCH_USES_PG_UNCACHED=y +CONFIG_ARCH_RANDOM=y +CONFIG_X86_SMAP=y +CONFIG_X86_INTEL_MPX=y +CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y +CONFIG_EFI=y +CONFIG_EFI_STUB=y +CONFIG_EFI_MIXED=y +CONFIG_SECCOMP=y +# CONFIG_HZ_100 is not set +CONFIG_HZ_250=y +# CONFIG_HZ_300 is not set +# CONFIG_HZ_1000 is not set +CONFIG_HZ=250 +CONFIG_SCHED_HRTICK=y +CONFIG_KEXEC=y +CONFIG_KEXEC_FILE=y +CONFIG_KEXEC_VERIFY_SIG=y +CONFIG_KEXEC_BZIMAGE_VERIFY_SIG=y +CONFIG_CRASH_DUMP=y +CONFIG_KEXEC_JUMP=y +CONFIG_PHYSICAL_START=0x1000000 +CONFIG_RELOCATABLE=y +CONFIG_RANDOMIZE_BASE=y +CONFIG_X86_NEED_RELOCS=y +CONFIG_PHYSICAL_ALIGN=0x200000 +CONFIG_RANDOMIZE_MEMORY=y +CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING=0xa +CONFIG_HOTPLUG_CPU=y +# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set +# CONFIG_DEBUG_HOTPLUG_CPU0 is not set +# CONFIG_COMPAT_VDSO is not set +# CONFIG_LEGACY_VSYSCALL_NATIVE is not set +CONFIG_LEGACY_VSYSCALL_EMULATE=y +# CONFIG_LEGACY_VSYSCALL_NONE is not set +# CONFIG_CMDLINE_BOOL is not set +CONFIG_MODIFY_LDT_SYSCALL=y +CONFIG_HAVE_LIVEPATCH=y +CONFIG_LIVEPATCH=y +CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y +CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y +CONFIG_USE_PERCPU_NUMA_NODE_ID=y + +# +# Power management and ACPI options +# +CONFIG_ARCH_HIBERNATION_HEADER=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_SUSPEND_SKIP_SYNC is not set +CONFIG_HIBERNATE_CALLBACKS=y +CONFIG_HIBERNATION=y +CONFIG_PM_STD_PARTITION="" +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +# CONFIG_PM_AUTOSLEEP is not set +CONFIG_PM_WAKELOCKS=y +CONFIG_PM_WAKELOCKS_LIMIT=100 +CONFIG_PM_WAKELOCKS_GC=y +CONFIG_PM=y +CONFIG_PM_DEBUG=y +CONFIG_PM_ADVANCED_DEBUG=y +# CONFIG_PM_TEST_SUSPEND is not set +CONFIG_PM_SLEEP_DEBUG=y +# CONFIG_DPM_WATCHDOG is not set +CONFIG_PM_TRACE=y +CONFIG_PM_TRACE_RTC=y +CONFIG_PM_CLK=y +CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y +CONFIG_ACPI=y +CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y +CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y +CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y +# CONFIG_ACPI_DEBUGGER is not set +CONFIG_ACPI_SLEEP=y +# CONFIG_ACPI_PROCFS_POWER is not set +CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y +# CONFIG_ACPI_EC_DEBUGFS is not set +CONFIG_ACPI_AC=y +CONFIG_ACPI_BATTERY=y +CONFIG_ACPI_BUTTON=y +# CONFIG_ACPI_VIDEO is not set +CONFIG_ACPI_FAN=y +CONFIG_ACPI_DOCK=y +CONFIG_ACPI_CPU_FREQ_PSS=y +CONFIG_ACPI_PROCESSOR_CSTATE=y +CONFIG_ACPI_PROCESSOR_IDLE=y +CONFIG_ACPI_CPPC_LIB=y +CONFIG_ACPI_PROCESSOR=y +CONFIG_ACPI_HOTPLUG_CPU=y +# CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set +CONFIG_ACPI_THERMAL=y +CONFIG_ACPI_NUMA=y +CONFIG_ACPI_CUSTOM_DSDT_FILE="" +# CONFIG_ACPI_CUSTOM_DSDT is not set +CONFIG_ARCH_HAS_ACPI_TABLE_UPGRADE=y +CONFIG_ACPI_TABLE_UPGRADE=y +# CONFIG_ACPI_DEBUG is not set +CONFIG_ACPI_PCI_SLOT=y +CONFIG_X86_PM_TIMER=y +CONFIG_ACPI_CONTAINER=y +CONFIG_ACPI_HOTPLUG_MEMORY=y +CONFIG_ACPI_HOTPLUG_IOAPIC=y +# CONFIG_ACPI_SBS is not set +CONFIG_ACPI_HED=y +# CONFIG_ACPI_CUSTOM_METHOD is not set +CONFIG_ACPI_BGRT=y +# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set +CONFIG_ACPI_NFIT=m +# CONFIG_ACPI_NFIT_DEBUG is not set +CONFIG_HAVE_ACPI_APEI=y +CONFIG_HAVE_ACPI_APEI_NMI=y +CONFIG_ACPI_APEI=y +CONFIG_ACPI_APEI_GHES=y +CONFIG_ACPI_APEI_PCIEAER=y +CONFIG_ACPI_APEI_MEMORY_FAILURE=y +# CONFIG_ACPI_APEI_EINJ is not set +# CONFIG_ACPI_APEI_ERST_DEBUG is not set +# CONFIG_DPTF_POWER is not set +# CONFIG_ACPI_EXTLOG is not set +# CONFIG_PMIC_OPREGION is not set +# CONFIG_ACPI_CONFIGFS is not set +CONFIG_SFI=y + +# +# CPU Frequency scaling +# +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set + +# +# CPU frequency scaling drivers +# +CONFIG_X86_INTEL_PSTATE=y +CONFIG_X86_PCC_CPUFREQ=y +CONFIG_X86_ACPI_CPUFREQ=y +CONFIG_X86_ACPI_CPUFREQ_CPB=y +CONFIG_X86_POWERNOW_K8=y +# CONFIG_X86_AMD_FREQ_SENSITIVITY is not set +CONFIG_X86_SPEEDSTEP_CENTRINO=y +# CONFIG_X86_P4_CLOCKMOD is not set + +# +# shared options +# +# CONFIG_X86_SPEEDSTEP_LIB is not set + +# +# CPU Idle +# +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_IDLE_GOV_MENU=y +# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set +CONFIG_INTEL_IDLE=y + +# +# Bus options (PCI etc.) +# +CONFIG_PCI=y +CONFIG_PCI_DIRECT=y +CONFIG_PCI_MMCONFIG=y +CONFIG_PCI_XEN=y +CONFIG_PCI_DOMAINS=y +# CONFIG_PCI_CNB20LE_QUIRK is not set +CONFIG_PCIEPORTBUS=y +CONFIG_HOTPLUG_PCI_PCIE=y +CONFIG_PCIEAER=y +# CONFIG_PCIE_ECRC is not set +# CONFIG_PCIEAER_INJECT is not set +CONFIG_PCIEASPM=y +CONFIG_PCIEASPM_DEBUG=y +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +# CONFIG_PCIEASPM_PERFORMANCE is not set +CONFIG_PCIE_PME=y +CONFIG_PCIE_DPC=y +# CONFIG_PCIE_PTM is not set +CONFIG_PCI_BUS_ADDR_T_64BIT=y +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +# CONFIG_PCI_DEBUG is not set +CONFIG_PCI_REALLOC_ENABLE_AUTO=y +# CONFIG_PCI_STUB is not set +# CONFIG_XEN_PCIDEV_FRONTEND is not set +CONFIG_HT_IRQ=y +CONFIG_PCI_ATS=y +CONFIG_PCI_IOV=y +CONFIG_PCI_PRI=y +CONFIG_PCI_PASID=y +CONFIG_PCI_LABEL=y +CONFIG_HOTPLUG_PCI=y +CONFIG_HOTPLUG_PCI_ACPI=y +# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set +CONFIG_HOTPLUG_PCI_CPCI=y +# CONFIG_HOTPLUG_PCI_CPCI_ZT5550 is not set +# CONFIG_HOTPLUG_PCI_CPCI_GENERIC is not set +CONFIG_HOTPLUG_PCI_SHPC=m + +# +# DesignWare PCI Core Support +# +CONFIG_PCIE_DW=y +CONFIG_PCIE_DW_HOST=y +CONFIG_PCIE_DW_PLAT=y + +# +# PCI host controller drivers +# +# CONFIG_VMD is not set +CONFIG_ISA_BUS=y +CONFIG_ISA_DMA_API=y +CONFIG_AMD_NB=y +# CONFIG_PCCARD is not set +CONFIG_RAPIDIO=y +# CONFIG_RAPIDIO_TSI721 is not set +CONFIG_RAPIDIO_DISC_TIMEOUT=30 +# CONFIG_RAPIDIO_ENABLE_RX_TX_PORTS is not set +CONFIG_RAPIDIO_DMA_ENGINE=y +# CONFIG_RAPIDIO_DEBUG is not set +# CONFIG_RAPIDIO_ENUM_BASIC is not set +# CONFIG_RAPIDIO_CHMAN is not set +# CONFIG_RAPIDIO_MPORT_CDEV is not set + +# +# RapidIO Switch drivers +# +# CONFIG_RAPIDIO_TSI57X is not set +# CONFIG_RAPIDIO_CPS_XX is not set +# CONFIG_RAPIDIO_TSI568 is not set +# CONFIG_RAPIDIO_CPS_GEN2 is not set +# CONFIG_RAPIDIO_RXS_GEN3 is not set +# CONFIG_X86_SYSFB is not set + +# +# Executable file formats / Emulations +# +CONFIG_BINFMT_ELF=y +CONFIG_COMPAT_BINFMT_ELF=y +CONFIG_ELFCORE=y +CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y +CONFIG_BINFMT_SCRIPT=y +# CONFIG_HAVE_AOUT is not set +# CONFIG_BINFMT_MISC is not set +CONFIG_COREDUMP=y +CONFIG_IA32_EMULATION=y +# CONFIG_IA32_AOUT is not set +CONFIG_X86_X32=y +CONFIG_COMPAT_32=y +CONFIG_COMPAT=y +CONFIG_COMPAT_FOR_U64_ALIGNMENT=y +CONFIG_SYSVIPC_COMPAT=y +CONFIG_KEYS_COMPAT=y +CONFIG_X86_DEV_DMA_OPS=y +CONFIG_NET=y +CONFIG_NET_INGRESS=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +CONFIG_UNIX=y +# CONFIG_UNIX_DIAG is not set +# CONFIG_XFRM_USER is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_FIB_TRIE_STATS=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +# CONFIG_IP_PNP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE_DEMUX is not set +# CONFIG_NET_IP_TUNNEL is not set +CONFIG_IP_MROUTE=y +# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set +CONFIG_IP_PIMSM_V1=y +CONFIG_IP_PIMSM_V2=y +CONFIG_SYN_COOKIES=y +# CONFIG_NET_UDP_TUNNEL is not set +# CONFIG_NET_FOU is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +# CONFIG_INET_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_DIAG is not set +CONFIG_TCP_CONG_ADVANCED=y +# CONFIG_TCP_CONG_BIC is not set +CONFIG_TCP_CONG_CUBIC=y +# CONFIG_TCP_CONG_WESTWOOD is not set +# CONFIG_TCP_CONG_HTCP is not set +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_NV is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_TCP_CONG_LP is not set +# CONFIG_TCP_CONG_VENO is not set +# CONFIG_TCP_CONG_YEAH is not set +# CONFIG_TCP_CONG_ILLINOIS is not set +# CONFIG_TCP_CONG_DCTCP is not set +# CONFIG_TCP_CONG_CDG is not set +# CONFIG_TCP_CONG_BBR is not set +CONFIG_DEFAULT_CUBIC=y +# CONFIG_DEFAULT_RENO is not set +CONFIG_DEFAULT_TCP_CONG="cubic" +CONFIG_TCP_MD5SIG=y +CONFIG_IPV6=y +CONFIG_IPV6_ROUTER_PREF=y +CONFIG_IPV6_ROUTE_INFO=y +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_IPV6_ILA is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET6_XFRM_MODE_TUNNEL is not set +# CONFIG_INET6_XFRM_MODE_BEET is not set +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +# CONFIG_IPV6_SIT is not set +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_FOU is not set +# CONFIG_IPV6_FOU_TUNNEL is not set +CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_IPV6_SUBTREES=y +CONFIG_IPV6_MROUTE=y +CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y +CONFIG_IPV6_PIMSM_V2=y +# CONFIG_IPV6_SEG6_LWTUNNEL is not set +# CONFIG_IPV6_SEG6_HMAC is not set +CONFIG_NETLABEL=y +CONFIG_NETWORK_SECMARK=y +# CONFIG_NET_PTP_CLASSIFY is not set +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set +CONFIG_NETFILTER=y +# CONFIG_NETFILTER_DEBUG is not set +CONFIG_NETFILTER_ADVANCED=y + +# +# Core Netfilter Configuration +# +CONFIG_NETFILTER_INGRESS=y +# CONFIG_NETFILTER_NETLINK_ACCT is not set +# CONFIG_NETFILTER_NETLINK_QUEUE is not set +# CONFIG_NETFILTER_NETLINK_LOG is not set +# CONFIG_NF_CONNTRACK is not set +# CONFIG_NF_LOG_NETDEV is not set +# CONFIG_NF_TABLES is not set +# CONFIG_NETFILTER_XTABLES is not set +# CONFIG_IP_SET is not set +# CONFIG_IP_VS is not set + +# +# IP: Netfilter Configuration +# +# CONFIG_NF_DEFRAG_IPV4 is not set +# CONFIG_NF_SOCKET_IPV4 is not set +# CONFIG_NF_DUP_IPV4 is not set +# CONFIG_NF_LOG_ARP is not set +# CONFIG_NF_LOG_IPV4 is not set +# CONFIG_NF_REJECT_IPV4 is not set +# CONFIG_IP_NF_IPTABLES is not set +# CONFIG_IP_NF_ARPTABLES is not set + +# +# IPv6: Netfilter Configuration +# +# CONFIG_NF_DEFRAG_IPV6 is not set +# CONFIG_NF_SOCKET_IPV6 is not set +# CONFIG_NF_DUP_IPV6 is not set +# CONFIG_NF_REJECT_IPV6 is not set +# CONFIG_NF_LOG_IPV6 is not set +# CONFIG_IP6_NF_IPTABLES is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_RDS is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_L2TP is not set +# CONFIG_BRIDGE is not set +CONFIG_HAVE_NET_DSA=y +# CONFIG_NET_DSA is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_PHONET is not set +# CONFIG_6LOWPAN is not set +# CONFIG_IEEE802154 is not set +CONFIG_NET_SCHED=y + +# +# Queueing/Scheduling +# +# CONFIG_NET_SCH_CBQ is not set +# CONFIG_NET_SCH_HTB is not set +# CONFIG_NET_SCH_HFSC is not set +# CONFIG_NET_SCH_PRIO is not set +# CONFIG_NET_SCH_MULTIQ is not set +# CONFIG_NET_SCH_RED is not set +# CONFIG_NET_SCH_SFB is not set +# CONFIG_NET_SCH_SFQ is not set +# CONFIG_NET_SCH_TEQL is not set +# CONFIG_NET_SCH_TBF is not set +# CONFIG_NET_SCH_GRED is not set +# CONFIG_NET_SCH_DSMARK is not set +# CONFIG_NET_SCH_NETEM is not set +# CONFIG_NET_SCH_DRR is not set +# CONFIG_NET_SCH_MQPRIO is not set +# CONFIG_NET_SCH_CHOKE is not set +# CONFIG_NET_SCH_QFQ is not set +# CONFIG_NET_SCH_CODEL is not set +# CONFIG_NET_SCH_FQ_CODEL is not set +# CONFIG_NET_SCH_FQ is not set +# CONFIG_NET_SCH_HHF is not set +# CONFIG_NET_SCH_PIE is not set +# CONFIG_NET_SCH_INGRESS is not set +# CONFIG_NET_SCH_PLUG is not set + +# +# Classification +# +CONFIG_NET_CLS=y +# CONFIG_NET_CLS_BASIC is not set +# CONFIG_NET_CLS_TCINDEX is not set +# CONFIG_NET_CLS_ROUTE4 is not set +# CONFIG_NET_CLS_FW is not set +# CONFIG_NET_CLS_U32 is not set +# CONFIG_NET_CLS_RSVP is not set +# CONFIG_NET_CLS_RSVP6 is not set +# CONFIG_NET_CLS_FLOW is not set +# CONFIG_NET_CLS_CGROUP is not set +# CONFIG_NET_CLS_BPF is not set +# CONFIG_NET_CLS_FLOWER is not set +# CONFIG_NET_CLS_MATCHALL is not set +CONFIG_NET_EMATCH=y +CONFIG_NET_EMATCH_STACK=32 +# CONFIG_NET_EMATCH_CMP is not set +# CONFIG_NET_EMATCH_NBYTE is not set +# CONFIG_NET_EMATCH_U32 is not set +# CONFIG_NET_EMATCH_META is not set +# CONFIG_NET_EMATCH_TEXT is not set +CONFIG_NET_CLS_ACT=y +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_SAMPLE is not set +# CONFIG_NET_ACT_NAT is not set +# CONFIG_NET_ACT_PEDIT is not set +# CONFIG_NET_ACT_SIMP is not set +# CONFIG_NET_ACT_SKBEDIT is not set +# CONFIG_NET_ACT_CSUM is not set +# CONFIG_NET_ACT_VLAN is not set +# CONFIG_NET_ACT_BPF is not set +# CONFIG_NET_ACT_SKBMOD is not set +# CONFIG_NET_ACT_IFE is not set +# CONFIG_NET_ACT_TUNNEL_KEY is not set +CONFIG_NET_SCH_FIFO=y +CONFIG_DCB=y +CONFIG_DNS_RESOLVER=y +# CONFIG_BATMAN_ADV is not set +# CONFIG_OPENVSWITCH is not set +CONFIG_VSOCKETS=m +CONFIG_VMWARE_VMCI_VSOCKETS=m +# CONFIG_VIRTIO_VSOCKETS is not set +# CONFIG_NETLINK_DIAG is not set +CONFIG_MPLS=y +# CONFIG_NET_MPLS_GSO is not set +# CONFIG_MPLS_ROUTING is not set +# CONFIG_HSR is not set +CONFIG_NET_SWITCHDEV=y +CONFIG_NET_L3_MASTER_DEV=y +CONFIG_NET_NCSI=y +CONFIG_RPS=y +CONFIG_RFS_ACCEL=y +CONFIG_XPS=y +CONFIG_CGROUP_NET_PRIO=y +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_NET_RX_BUSY_POLL=y +CONFIG_BQL=y +CONFIG_BPF_JIT=y +CONFIG_NET_FLOW_LIMIT=y + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NET_TCPPROBE is not set +# CONFIG_NET_DROP_MONITOR is not set +CONFIG_HAMRADIO=y + +# +# Packet Radio protocols +# +# CONFIG_AX25 is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +CONFIG_BT=m +CONFIG_BT_BREDR=y +CONFIG_BT_RFCOMM=m +CONFIG_BT_RFCOMM_TTY=y +CONFIG_BT_BNEP=m +CONFIG_BT_BNEP_MC_FILTER=y +CONFIG_BT_BNEP_PROTO_FILTER=y +# CONFIG_BT_HIDP is not set +CONFIG_BT_HS=y +CONFIG_BT_LE=y +CONFIG_BT_LEDS=y +# CONFIG_BT_SELFTEST is not set +CONFIG_BT_DEBUGFS=y + +# +# Bluetooth device drivers +# +CONFIG_BT_INTEL=m +CONFIG_BT_BCM=m +CONFIG_BT_RTL=m +CONFIG_BT_HCIBTUSB=m +CONFIG_BT_HCIBTUSB_BCM=y +CONFIG_BT_HCIBTUSB_RTL=y +# CONFIG_BT_HCIBTSDIO is not set +# CONFIG_BT_HCIUART is not set +# CONFIG_BT_HCIBCM203X is not set +# CONFIG_BT_HCIBFUSB is not set +# CONFIG_BT_HCIVHCI is not set +# CONFIG_BT_MRVL is not set +# CONFIG_BT_ATH3K is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_AF_KCM is not set +# CONFIG_STREAM_PARSER is not set +CONFIG_FIB_RULES=y +CONFIG_WIRELESS=y +# CONFIG_CFG80211 is not set +# CONFIG_LIB80211 is not set + +# +# CFG80211 needs to be enabled for MAC80211 +# +CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 +# CONFIG_WIMAX is not set +CONFIG_RFKILL=y +CONFIG_RFKILL_LEDS=y +CONFIG_RFKILL_INPUT=y +# CONFIG_RFKILL_GPIO is not set +# CONFIG_NET_9P is not set +# CONFIG_CAIF is not set +# CONFIG_CEPH_LIB is not set +# CONFIG_NFC is not set +# CONFIG_PSAMPLE is not set +# CONFIG_NET_IFE is not set +CONFIG_LWTUNNEL=y +CONFIG_LWTUNNEL_BPF=y +# CONFIG_DST_CACHE is not set +# CONFIG_GRO_CELLS is not set +# CONFIG_NET_DEVLINK is not set +CONFIG_MAY_USE_DEVLINK=y +CONFIG_HAVE_EBPF_JIT=y + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER=y +CONFIG_UEVENT_HELPER_PATH="" +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_STANDALONE is not set +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_FW_LOADER_USER_HELPER_FALLBACK is not set +CONFIG_ALLOW_DEV_COREDUMP=y +# CONFIG_DEBUG_DRIVER is not set +# CONFIG_DEBUG_DEVRES is not set +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set +# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set +CONFIG_SYS_HYPERVISOR=y +# CONFIG_GENERIC_CPU_DEVICES is not set +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_SPI=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGMAP_IRQ=y +CONFIG_DMA_SHARED_BUFFER=y +# CONFIG_DMA_FENCE_TRACE is not set +# CONFIG_DMA_CMA is not set + +# +# Bus devices +# +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +# CONFIG_MTD is not set +# CONFIG_OF is not set +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_PARPORT=m +CONFIG_PARPORT_PC=m +# CONFIG_PARPORT_SERIAL is not set +CONFIG_PARPORT_PC_FIFO=y +# CONFIG_PARPORT_PC_SUPERIO is not set +# CONFIG_PARPORT_GSC is not set +# CONFIG_PARPORT_AX88796 is not set +CONFIG_PARPORT_1284=y +CONFIG_PNP=y +# CONFIG_PNP_DEBUG_MESSAGES is not set + +# +# Protocols +# +CONFIG_PNPACPI=y +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_NULL_BLK is not set +CONFIG_BLK_DEV_FD=m +# CONFIG_PARIDE is not set +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set +# CONFIG_ZRAM is not set +# CONFIG_BLK_CPQ_CISS_DA is not set +# CONFIG_BLK_DEV_DAC960 is not set +# CONFIG_BLK_DEV_UMEM is not set +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +# CONFIG_BLK_DEV_DRBD is not set +# CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_SKD is not set +# CONFIG_BLK_DEV_SX8 is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=65536 +CONFIG_BLK_DEV_RAM_DAX=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_XEN_BLKDEV_FRONTEND=y +# CONFIG_XEN_BLKDEV_BACKEND is not set +# CONFIG_VIRTIO_BLK is not set +# CONFIG_BLK_DEV_HD is not set +# CONFIG_BLK_DEV_RBD is not set +# CONFIG_BLK_DEV_RSXX is not set +# CONFIG_BLK_DEV_NVME is not set +# CONFIG_NVME_FC is not set + +# +# Misc devices +# +# CONFIG_SENSORS_LIS3LV02D is not set +# CONFIG_AD525X_DPOT is not set +# CONFIG_DUMMY_IRQ is not set +# CONFIG_IBM_ASM is not set +# CONFIG_PHANTOM is not set +# CONFIG_SGI_IOC4 is not set +# CONFIG_TIFM_CORE is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_HP_ILO is not set +# CONFIG_APDS9802ALS is not set +# CONFIG_ISL29003 is not set +# CONFIG_ISL29020 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_SENSORS_BH1770 is not set +# CONFIG_SENSORS_APDS990X is not set +# CONFIG_HMC6352 is not set +# CONFIG_DS1682 is not set +# CONFIG_TI_DAC7512 is not set +CONFIG_VMWARE_BALLOON=m +# CONFIG_USB_SWITCH_FSA9480 is not set +# CONFIG_LATTICE_ECP3_CONFIG is not set +CONFIG_SRAM=y +# CONFIG_PANEL is not set +# CONFIG_C2PORT is not set + +# +# EEPROM support +# +# CONFIG_EEPROM_AT24 is not set +# CONFIG_EEPROM_AT25 is not set +# CONFIG_EEPROM_LEGACY is not set +# CONFIG_EEPROM_MAX6875 is not set +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_EEPROM_93XX46 is not set +# CONFIG_EEPROM_IDT_89HPESX is not set +# CONFIG_CB710_CORE is not set + +# +# Texas Instruments shared transport line discipline +# +# CONFIG_TI_ST is not set +# CONFIG_SENSORS_LIS3_I2C is not set + +# +# Altera FPGA firmware download module +# +# CONFIG_ALTERA_STAPL is not set +# CONFIG_INTEL_MEI is not set +# CONFIG_INTEL_MEI_ME is not set +# CONFIG_INTEL_MEI_TXE is not set +CONFIG_VMWARE_VMCI=m + +# +# Intel MIC Bus Driver +# +# CONFIG_INTEL_MIC_BUS is not set + +# +# SCIF Bus Driver +# +# CONFIG_SCIF_BUS is not set + +# +# VOP Bus Driver +# +# CONFIG_VOP_BUS is not set + +# +# Intel MIC Host Driver +# + +# +# Intel MIC Card Driver +# + +# +# SCIF Driver +# + +# +# Intel MIC Coprocessor State Management (COSM) Drivers +# + +# +# VOP Driver +# +# CONFIG_GENWQE is not set +# CONFIG_ECHO is not set +# CONFIG_CXL_BASE is not set +# CONFIG_CXL_AFU_DRIVER_OPS is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +CONFIG_SCSI_MOD=y +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_NETLINK=y +# CONFIG_SCSI_MQ_DEFAULT is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +CONFIG_BLK_DEV_SR=y +# CONFIG_BLK_DEV_SR_VENDOR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set +CONFIG_SCSI_CONSTANTS=y +CONFIG_SCSI_LOGGING=y +CONFIG_SCSI_SCAN_ASYNC=y + +# +# SCSI Transports +# +CONFIG_SCSI_SPI_ATTRS=m +CONFIG_SCSI_FC_ATTRS=m +# CONFIG_SCSI_ISCSI_ATTRS is not set +CONFIG_SCSI_SAS_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +CONFIG_SCSI_LOWLEVEL=y +# CONFIG_ISCSI_TCP is not set +# CONFIG_ISCSI_BOOT_SYSFS is not set +# CONFIG_SCSI_CXGB3_ISCSI is not set +# CONFIG_SCSI_CXGB4_ISCSI is not set +# CONFIG_SCSI_BNX2_ISCSI is not set +# CONFIG_BE2ISCSI is not set +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set +# CONFIG_SCSI_HPSA is not set +# CONFIG_SCSI_3W_9XXX is not set +# CONFIG_SCSI_3W_SAS is not set +# CONFIG_SCSI_ACARD is not set +# CONFIG_SCSI_AACRAID is not set +# CONFIG_SCSI_AIC7XXX is not set +# CONFIG_SCSI_AIC79XX is not set +# CONFIG_SCSI_AIC94XX is not set +# CONFIG_SCSI_MVSAS is not set +# CONFIG_SCSI_MVUMI is not set +# CONFIG_SCSI_DPT_I2O is not set +# CONFIG_SCSI_ADVANSYS is not set +# CONFIG_SCSI_ARCMSR is not set +# CONFIG_SCSI_ESAS2R is not set +CONFIG_MEGARAID_NEWGEN=y +# CONFIG_MEGARAID_MM is not set +# CONFIG_MEGARAID_LEGACY is not set +# CONFIG_MEGARAID_SAS is not set +# CONFIG_SCSI_MPT3SAS is not set +# CONFIG_SCSI_MPT2SAS is not set +# CONFIG_SCSI_SMARTPQI is not set +# CONFIG_SCSI_UFSHCD is not set +# CONFIG_SCSI_HPTIOP is not set +# CONFIG_SCSI_BUSLOGIC is not set +# CONFIG_VMWARE_PVSCSI is not set +# CONFIG_XEN_SCSI_FRONTEND is not set +# CONFIG_LIBFC is not set +# CONFIG_SCSI_SNIC is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_FUTURE_DOMAIN is not set +# CONFIG_SCSI_GDTH is not set +# CONFIG_SCSI_ISCI is not set +# CONFIG_SCSI_IPS is not set +# CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_INIA100 is not set +# CONFIG_SCSI_PPA is not set +# CONFIG_SCSI_IMM is not set +# CONFIG_SCSI_STEX is not set +# CONFIG_SCSI_SYM53C8XX_2 is not set +# CONFIG_SCSI_IPR is not set +# CONFIG_SCSI_QLOGIC_1280 is not set +# CONFIG_SCSI_QLA_FC is not set +# CONFIG_SCSI_QLA_ISCSI is not set +# CONFIG_SCSI_LPFC is not set +# CONFIG_SCSI_DC395x is not set +# CONFIG_SCSI_AM53C974 is not set +# CONFIG_SCSI_WD719X is not set +# CONFIG_SCSI_DEBUG is not set +# CONFIG_SCSI_PMCRAID is not set +# CONFIG_SCSI_PM8001 is not set +# CONFIG_SCSI_BFA_FC is not set +# CONFIG_SCSI_VIRTIO is not set +# CONFIG_SCSI_CHELSIO_FCOE is not set +CONFIG_SCSI_DH=y +# CONFIG_SCSI_DH_RDAC is not set +# CONFIG_SCSI_DH_HP_SW is not set +# CONFIG_SCSI_DH_EMC is not set +# CONFIG_SCSI_DH_ALUA is not set +# CONFIG_SCSI_OSD_INITIATOR is not set +CONFIG_ATA=y +# CONFIG_ATA_NONSTANDARD is not set +CONFIG_ATA_VERBOSE_ERROR=y +CONFIG_ATA_ACPI=y +CONFIG_SATA_ZPODD=y +CONFIG_SATA_PMP=y + +# +# Controllers with non-SFF native interface +# +CONFIG_SATA_AHCI=m +CONFIG_SATA_AHCI_PLATFORM=m +# CONFIG_SATA_INIC162X is not set +CONFIG_SATA_ACARD_AHCI=m +# CONFIG_SATA_SIL24 is not set +CONFIG_ATA_SFF=y + +# +# SFF controllers with custom DMA interface +# +# CONFIG_PDC_ADMA is not set +# CONFIG_SATA_QSTOR is not set +# CONFIG_SATA_SX4 is not set +CONFIG_ATA_BMDMA=y + +# +# SATA SFF controllers with BMDMA +# +CONFIG_ATA_PIIX=y +# CONFIG_SATA_DWC is not set +# CONFIG_SATA_MV is not set +# CONFIG_SATA_NV is not set +# CONFIG_SATA_PROMISE is not set +# CONFIG_SATA_SIL is not set +# CONFIG_SATA_SIS is not set +# CONFIG_SATA_SVW is not set +# CONFIG_SATA_ULI is not set +# CONFIG_SATA_VIA is not set +# CONFIG_SATA_VITESSE is not set + +# +# PATA SFF controllers with BMDMA +# +# CONFIG_PATA_ALI is not set +# CONFIG_PATA_AMD is not set +# CONFIG_PATA_ARTOP is not set +# CONFIG_PATA_ATIIXP is not set +# CONFIG_PATA_ATP867X is not set +# CONFIG_PATA_CMD64X is not set +# CONFIG_PATA_CYPRESS is not set +# CONFIG_PATA_EFAR is not set +# CONFIG_PATA_HPT366 is not set +# CONFIG_PATA_HPT37X is not set +# CONFIG_PATA_HPT3X2N is not set +# CONFIG_PATA_HPT3X3 is not set +# CONFIG_PATA_IT8213 is not set +# CONFIG_PATA_IT821X is not set +# CONFIG_PATA_JMICRON is not set +# CONFIG_PATA_MARVELL is not set +# CONFIG_PATA_NETCELL is not set +# CONFIG_PATA_NINJA32 is not set +# CONFIG_PATA_NS87415 is not set +# CONFIG_PATA_OLDPIIX is not set +# CONFIG_PATA_OPTIDMA is not set +# CONFIG_PATA_PDC2027X is not set +# CONFIG_PATA_PDC_OLD is not set +# CONFIG_PATA_RADISYS is not set +# CONFIG_PATA_RDC is not set +# CONFIG_PATA_SCH is not set +# CONFIG_PATA_SERVERWORKS is not set +# CONFIG_PATA_SIL680 is not set +CONFIG_PATA_SIS=y +# CONFIG_PATA_TOSHIBA is not set +# CONFIG_PATA_TRIFLEX is not set +# CONFIG_PATA_VIA is not set +# CONFIG_PATA_WINBOND is not set + +# +# PIO-only SFF controllers +# +# CONFIG_PATA_CMD640_PCI is not set +# CONFIG_PATA_MPIIX is not set +# CONFIG_PATA_NS87410 is not set +# CONFIG_PATA_OPTI is not set +# CONFIG_PATA_PLATFORM is not set +# CONFIG_PATA_RZ1000 is not set + +# +# Generic fallback / legacy drivers +# +CONFIG_PATA_ACPI=m +CONFIG_ATA_GENERIC=y +# CONFIG_PATA_LEGACY is not set +CONFIG_MD=y +CONFIG_BLK_DEV_MD=y +CONFIG_MD_AUTODETECT=y +# CONFIG_MD_LINEAR is not set +# CONFIG_MD_RAID0 is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID10 is not set +# CONFIG_MD_RAID456 is not set +# CONFIG_MD_MULTIPATH is not set +# CONFIG_MD_FAULTY is not set +# CONFIG_BCACHE is not set +CONFIG_BLK_DEV_DM_BUILTIN=y +CONFIG_BLK_DEV_DM=y +# CONFIG_DM_MQ_DEFAULT is not set +# CONFIG_DM_DEBUG is not set +# CONFIG_DM_CRYPT is not set +# CONFIG_DM_SNAPSHOT is not set +# CONFIG_DM_THIN_PROVISIONING is not set +# CONFIG_DM_CACHE is not set +# CONFIG_DM_ERA is not set +# CONFIG_DM_MIRROR is not set +# CONFIG_DM_RAID is not set +# CONFIG_DM_ZERO is not set +# CONFIG_DM_MULTIPATH is not set +# CONFIG_DM_DELAY is not set +CONFIG_DM_UEVENT=y +# CONFIG_DM_FLAKEY is not set +# CONFIG_DM_VERITY is not set +# CONFIG_DM_SWITCH is not set +# CONFIG_DM_LOG_WRITES is not set +# CONFIG_TARGET_CORE is not set +CONFIG_FUSION=y +CONFIG_FUSION_SPI=m +CONFIG_FUSION_FC=m +CONFIG_FUSION_SAS=m +CONFIG_FUSION_MAX_SGE=128 +# CONFIG_FUSION_CTL is not set +# CONFIG_FUSION_LAN is not set +CONFIG_FUSION_LOGGING=y + +# +# IEEE 1394 (FireWire) support +# +# CONFIG_FIREWIRE is not set +# CONFIG_FIREWIRE_NOSY is not set +CONFIG_MACINTOSH_DRIVERS=y +CONFIG_MAC_EMUMOUSEBTN=m +CONFIG_NETDEVICES=y +CONFIG_NET_CORE=y +# CONFIG_BONDING is not set +# CONFIG_DUMMY is not set +# CONFIG_EQUALIZER is not set +CONFIG_NET_FC=y +# CONFIG_IFB is not set +# CONFIG_NET_TEAM is not set +# CONFIG_MACVLAN is not set +# CONFIG_IPVLAN is not set +# CONFIG_VXLAN is not set +# CONFIG_MACSEC is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_RIONET is not set +CONFIG_TUN=y +# CONFIG_TUN_VNET_CROSS_LE is not set +# CONFIG_VETH is not set +# CONFIG_VIRTIO_NET is not set +# CONFIG_NLMON is not set +# CONFIG_NET_VRF is not set +# CONFIG_ARCNET is not set + +# +# CAIF transport drivers +# + +# +# Distributed Switch Architecture drivers +# +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_3COM=y +# CONFIG_VORTEX is not set +# CONFIG_TYPHOON is not set +CONFIG_NET_VENDOR_ADAPTEC=y +# CONFIG_ADAPTEC_STARFIRE is not set +CONFIG_NET_VENDOR_AGERE=y +# CONFIG_ET131X is not set +CONFIG_NET_VENDOR_ALACRITECH=y +# CONFIG_SLICOSS is not set +CONFIG_NET_VENDOR_ALTEON=y +# CONFIG_ACENIC is not set +# CONFIG_ALTERA_TSE is not set +CONFIG_NET_VENDOR_AMAZON=y +# CONFIG_ENA_ETHERNET is not set +CONFIG_NET_VENDOR_AMD=y +# CONFIG_AMD8111_ETH is not set +# CONFIG_PCNET32 is not set +# CONFIG_AMD_XGBE is not set +# CONFIG_AMD_XGBE_HAVE_ECC is not set +CONFIG_NET_VENDOR_AQUANTIA=y +# CONFIG_AQTION is not set +CONFIG_NET_VENDOR_ARC=y +CONFIG_NET_VENDOR_ATHEROS=y +# CONFIG_ATL2 is not set +# CONFIG_ATL1 is not set +# CONFIG_ATL1E is not set +# CONFIG_ATL1C is not set +# CONFIG_ALX is not set +CONFIG_NET_VENDOR_AURORA=y +# CONFIG_AURORA_NB8800 is not set +CONFIG_NET_CADENCE=y +# CONFIG_MACB is not set +CONFIG_NET_VENDOR_BROADCOM=y +# CONFIG_B44 is not set +# CONFIG_BCMGENET is not set +# CONFIG_BNX2 is not set +# CONFIG_CNIC is not set +# CONFIG_TIGON3 is not set +# CONFIG_BNX2X is not set +# CONFIG_BNXT is not set +CONFIG_NET_VENDOR_BROCADE=y +# CONFIG_BNA is not set +CONFIG_NET_VENDOR_CAVIUM=y +# CONFIG_THUNDER_NIC_PF is not set +# CONFIG_THUNDER_NIC_VF is not set +# CONFIG_THUNDER_NIC_BGX is not set +# CONFIG_THUNDER_NIC_RGX is not set +# CONFIG_LIQUIDIO is not set +# CONFIG_LIQUIDIO_VF is not set +CONFIG_NET_VENDOR_CHELSIO=y +# CONFIG_CHELSIO_T1 is not set +# CONFIG_CHELSIO_T3 is not set +# CONFIG_CHELSIO_T4 is not set +# CONFIG_CHELSIO_T4VF is not set +CONFIG_NET_VENDOR_CISCO=y +# CONFIG_ENIC is not set +# CONFIG_CX_ECAT is not set +# CONFIG_DNET is not set +CONFIG_NET_VENDOR_DEC=y +CONFIG_NET_TULIP=y +# CONFIG_DE2104X is not set +# CONFIG_TULIP is not set +# CONFIG_DE4X5 is not set +# CONFIG_WINBOND_840 is not set +# CONFIG_DM9102 is not set +# CONFIG_ULI526X is not set +CONFIG_NET_VENDOR_DLINK=y +# CONFIG_DL2K is not set +# CONFIG_SUNDANCE is not set +CONFIG_NET_VENDOR_EMULEX=y +# CONFIG_BE2NET is not set +CONFIG_NET_VENDOR_EZCHIP=y +CONFIG_NET_VENDOR_EXAR=y +# CONFIG_S2IO is not set +# CONFIG_VXGE is not set +CONFIG_NET_VENDOR_HP=y +# CONFIG_HP100 is not set +CONFIG_NET_VENDOR_INTEL=y +# CONFIG_E100 is not set +CONFIG_E1000=m +# CONFIG_E1000E is not set +# CONFIG_IGB is not set +# CONFIG_IGBVF is not set +# CONFIG_IXGB is not set +# CONFIG_IXGBE is not set +# CONFIG_IXGBEVF is not set +# CONFIG_I40E is not set +# CONFIG_I40EVF is not set +# CONFIG_FM10K is not set +CONFIG_NET_VENDOR_I825XX=y +# CONFIG_JME is not set +CONFIG_NET_VENDOR_MARVELL=y +# CONFIG_MVMDIO is not set +# CONFIG_SKGE is not set +# CONFIG_SKY2 is not set +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MLX4_EN is not set +# CONFIG_MLX4_CORE is not set +# CONFIG_MLX5_CORE is not set +# CONFIG_MLXSW_CORE is not set +CONFIG_NET_VENDOR_MICREL=y +# CONFIG_KS8842 is not set +# CONFIG_KS8851 is not set +# CONFIG_KS8851_MLL is not set +# CONFIG_KSZ884X_PCI is not set +CONFIG_NET_VENDOR_MICROCHIP=y +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set +CONFIG_NET_VENDOR_MYRI=y +# CONFIG_MYRI10GE is not set +# CONFIG_FEALNX is not set +CONFIG_NET_VENDOR_NATSEMI=y +# CONFIG_NATSEMI is not set +# CONFIG_NS83820 is not set +CONFIG_NET_VENDOR_NETRONOME=y +# CONFIG_NFP is not set +CONFIG_NET_VENDOR_8390=y +# CONFIG_NE2K_PCI is not set +CONFIG_NET_VENDOR_NVIDIA=y +# CONFIG_FORCEDETH is not set +CONFIG_NET_VENDOR_OKI=y +# CONFIG_ETHOC is not set +CONFIG_NET_PACKET_ENGINE=y +# CONFIG_HAMACHI is not set +# CONFIG_YELLOWFIN is not set +CONFIG_NET_VENDOR_QLOGIC=y +# CONFIG_QLA3XXX is not set +# CONFIG_QLCNIC is not set +# CONFIG_QLGE is not set +# CONFIG_NETXEN_NIC is not set +# CONFIG_QED is not set +CONFIG_NET_VENDOR_QUALCOMM=y +# CONFIG_QCOM_EMAC is not set +CONFIG_NET_VENDOR_REALTEK=y +# CONFIG_ATP is not set +# CONFIG_8139CP is not set +# CONFIG_8139TOO is not set +# CONFIG_R8169 is not set +CONFIG_NET_VENDOR_RENESAS=y +CONFIG_NET_VENDOR_RDC=y +# CONFIG_R6040 is not set +CONFIG_NET_VENDOR_ROCKER=y +CONFIG_NET_VENDOR_SAMSUNG=y +# CONFIG_SXGBE_ETH is not set +CONFIG_NET_VENDOR_SEEQ=y +CONFIG_NET_VENDOR_SILAN=y +# CONFIG_SC92031 is not set +CONFIG_NET_VENDOR_SIS=y +# CONFIG_SIS900 is not set +# CONFIG_SIS190 is not set +CONFIG_NET_VENDOR_SOLARFLARE=y +# CONFIG_SFC is not set +# CONFIG_SFC_FALCON is not set +CONFIG_NET_VENDOR_SMSC=y +# CONFIG_EPIC100 is not set +# CONFIG_SMSC911X is not set +# CONFIG_SMSC9420 is not set +CONFIG_NET_VENDOR_STMICRO=y +# CONFIG_STMMAC_ETH is not set +CONFIG_NET_VENDOR_SUN=y +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNGEM is not set +# CONFIG_CASSINI is not set +# CONFIG_NIU is not set +CONFIG_NET_VENDOR_TEHUTI=y +# CONFIG_TEHUTI is not set +CONFIG_NET_VENDOR_TI=y +# CONFIG_TI_CPSW_ALE is not set +# CONFIG_TLAN is not set +CONFIG_NET_VENDOR_VIA=y +# CONFIG_VIA_RHINE is not set +# CONFIG_VIA_VELOCITY is not set +CONFIG_NET_VENDOR_WIZNET=y +# CONFIG_WIZNET_W5100 is not set +# CONFIG_WIZNET_W5300 is not set +CONFIG_FDDI=y +# CONFIG_DEFXX is not set +# CONFIG_SKFP is not set +# CONFIG_HIPPI is not set +# CONFIG_NET_SB1000 is not set +CONFIG_PHYLIB=y +CONFIG_SWPHY=y +# CONFIG_LED_TRIGGER_PHY is not set + +# +# MDIO bus device drivers +# +# CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_MDIO_BITBANG is not set +# CONFIG_MDIO_OCTEON is not set +# CONFIG_MDIO_THUNDER is not set + +# +# MII PHY device drivers +# +# CONFIG_AMD_PHY is not set +# CONFIG_AQUANTIA_PHY is not set +# CONFIG_AT803X_PHY is not set +# CONFIG_BCM7XXX_PHY is not set +# CONFIG_BCM87XX_PHY is not set +# CONFIG_BROADCOM_PHY is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_DAVICOM_PHY is not set +# CONFIG_DP83848_PHY is not set +# CONFIG_DP83867_PHY is not set +CONFIG_FIXED_PHY=y +# CONFIG_ICPLUS_PHY is not set +# CONFIG_INTEL_XWAY_PHY is not set +# CONFIG_LSI_ET1011C_PHY is not set +# CONFIG_LXT_PHY is not set +# CONFIG_MARVELL_PHY is not set +# CONFIG_MICREL_PHY is not set +# CONFIG_MICROCHIP_PHY is not set +# CONFIG_MICROSEMI_PHY is not set +# CONFIG_NATIONAL_PHY is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_REALTEK_PHY is not set +# CONFIG_SMSC_PHY is not set +# CONFIG_STE10XP is not set +# CONFIG_TERANETICS_PHY is not set +# CONFIG_VITESSE_PHY is not set +# CONFIG_XILINX_GMII2RGMII is not set +# CONFIG_MICREL_KS8995MA is not set +# CONFIG_PLIP is not set +CONFIG_PPP=y +# CONFIG_PPP_BSDCOMP is not set +# CONFIG_PPP_DEFLATE is not set +CONFIG_PPP_FILTER=y +# CONFIG_PPP_MPPE is not set +CONFIG_PPP_MULTILINK=y +# CONFIG_PPPOE is not set +# CONFIG_PPP_ASYNC is not set +# CONFIG_PPP_SYNC_TTY is not set +# CONFIG_SLIP is not set +CONFIG_SLHC=y +# CONFIG_USB_NET_DRIVERS is not set +CONFIG_WLAN=y +# CONFIG_WIRELESS_WDS is not set +CONFIG_WLAN_VENDOR_ADMTEK=y +CONFIG_WLAN_VENDOR_ATH=y +# CONFIG_ATH_DEBUG is not set +CONFIG_ATH5K_PCI=y +CONFIG_WLAN_VENDOR_ATMEL=y +CONFIG_WLAN_VENDOR_BROADCOM=y +CONFIG_WLAN_VENDOR_CISCO=y +CONFIG_WLAN_VENDOR_INTEL=y +CONFIG_WLAN_VENDOR_INTERSIL=y +# CONFIG_HOSTAP is not set +# CONFIG_PRISM54 is not set +CONFIG_WLAN_VENDOR_MARVELL=y +CONFIG_WLAN_VENDOR_MEDIATEK=y +CONFIG_WLAN_VENDOR_RALINK=y +CONFIG_WLAN_VENDOR_REALTEK=y +CONFIG_WLAN_VENDOR_RSI=y +CONFIG_WLAN_VENDOR_ST=y +# CONFIG_WLAN_VENDOR_TI is not set +CONFIG_WLAN_VENDOR_ZYDAS=y + +# +# Enable WiMAX (Networking options) to see the WiMAX drivers +# +CONFIG_WAN=y +# CONFIG_HDLC is not set +# CONFIG_DLCI is not set +# CONFIG_SBNI is not set +CONFIG_XEN_NETDEV_FRONTEND=y +# CONFIG_XEN_NETDEV_BACKEND is not set +# CONFIG_VMXNET3 is not set +CONFIG_FUJITSU_ES=m +CONFIG_ISDN=y +# CONFIG_ISDN_I4L is not set +# CONFIG_ISDN_CAPI is not set +# CONFIG_ISDN_DRV_GIGASET is not set +# CONFIG_HYSDN is not set +# CONFIG_MISDN is not set +CONFIG_NVM=y +# CONFIG_NVM_DEBUG is not set +# CONFIG_NVM_RRPC is not set + +# +# Input device support +# +CONFIG_INPUT=y +CONFIG_INPUT_LEDS=m +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set +# CONFIG_INPUT_SPARSEKMAP is not set +# CONFIG_INPUT_MATRIXKMAP is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +CONFIG_INPUT_JOYDEV=m +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +# CONFIG_KEYBOARD_ADP5520 is not set +# CONFIG_KEYBOARD_ADP5588 is not set +# CONFIG_KEYBOARD_ADP5589 is not set +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_QT1070 is not set +# CONFIG_KEYBOARD_QT2160 is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_GPIO is not set +# CONFIG_KEYBOARD_GPIO_POLLED is not set +# CONFIG_KEYBOARD_TCA6416 is not set +# CONFIG_KEYBOARD_TCA8418 is not set +# CONFIG_KEYBOARD_MATRIX is not set +# CONFIG_KEYBOARD_LM8323 is not set +# CONFIG_KEYBOARD_LM8333 is not set +# CONFIG_KEYBOARD_MAX7359 is not set +# CONFIG_KEYBOARD_MCS is not set +# CONFIG_KEYBOARD_MPR121 is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_OPENCORES is not set +# CONFIG_KEYBOARD_SAMSUNG is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set +# CONFIG_KEYBOARD_TWL4030 is not set +# CONFIG_KEYBOARD_XTKBD is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=m +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_BYD=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_CYPRESS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +CONFIG_MOUSE_PS2_ELANTECH=y +CONFIG_MOUSE_PS2_SENTELIC=y +CONFIG_MOUSE_PS2_TOUCHKIT=y +CONFIG_MOUSE_PS2_FOCALTECH=y +CONFIG_MOUSE_PS2_VMMOUSE=y +# CONFIG_MOUSE_SERIAL is not set +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_CYAPA is not set +# CONFIG_MOUSE_ELAN_I2C is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_MOUSE_SYNAPTICS_I2C is not set +# CONFIG_MOUSE_SYNAPTICS_USB is not set +CONFIG_INPUT_JOYSTICK=y +# CONFIG_JOYSTICK_ANALOG is not set +# CONFIG_JOYSTICK_A3D is not set +# CONFIG_JOYSTICK_ADI is not set +# CONFIG_JOYSTICK_COBRA is not set +# CONFIG_JOYSTICK_GF2K is not set +# CONFIG_JOYSTICK_GRIP is not set +# CONFIG_JOYSTICK_GRIP_MP is not set +# CONFIG_JOYSTICK_GUILLEMOT is not set +# CONFIG_JOYSTICK_INTERACT is not set +# CONFIG_JOYSTICK_SIDEWINDER is not set +# CONFIG_JOYSTICK_TMDC is not set +# CONFIG_JOYSTICK_IFORCE is not set +# CONFIG_JOYSTICK_WARRIOR is not set +# CONFIG_JOYSTICK_MAGELLAN is not set +# CONFIG_JOYSTICK_SPACEORB is not set +# CONFIG_JOYSTICK_SPACEBALL is not set +# CONFIG_JOYSTICK_STINGER is not set +# CONFIG_JOYSTICK_TWIDJOY is not set +# CONFIG_JOYSTICK_ZHENHUA is not set +# CONFIG_JOYSTICK_DB9 is not set +# CONFIG_JOYSTICK_GAMECON is not set +# CONFIG_JOYSTICK_TURBOGRAFX is not set +# CONFIG_JOYSTICK_AS5011 is not set +# CONFIG_JOYSTICK_JOYDUMP is not set +# CONFIG_JOYSTICK_XPAD is not set +# CONFIG_JOYSTICK_WALKERA0701 is not set +CONFIG_INPUT_TABLET=y +# CONFIG_TABLET_USB_ACECAD is not set +# CONFIG_TABLET_USB_AIPTEK is not set +# CONFIG_TABLET_USB_GTCO is not set +# CONFIG_TABLET_USB_HANWANG is not set +# CONFIG_TABLET_USB_KBTAB is not set +# CONFIG_TABLET_USB_PEGASUS is not set +# CONFIG_TABLET_SERIAL_WACOM4 is not set +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_PROPERTIES=y +# CONFIG_TOUCHSCREEN_88PM860X is not set +# CONFIG_TOUCHSCREEN_ADS7846 is not set +# CONFIG_TOUCHSCREEN_AD7877 is not set +# CONFIG_TOUCHSCREEN_AD7879 is not set +# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set +# CONFIG_TOUCHSCREEN_AUO_PIXCIR is not set +# CONFIG_TOUCHSCREEN_BU21013 is not set +# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set +# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set +# CONFIG_TOUCHSCREEN_CYTTSP4_CORE is not set +# CONFIG_TOUCHSCREEN_DA9034 is not set +# CONFIG_TOUCHSCREEN_DA9052 is not set +# CONFIG_TOUCHSCREEN_DYNAPRO is not set +# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set +# CONFIG_TOUCHSCREEN_EETI is not set +# CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set +# CONFIG_TOUCHSCREEN_FUJITSU is not set +# CONFIG_TOUCHSCREEN_GOODIX is not set +# CONFIG_TOUCHSCREEN_ILI210X is not set +# CONFIG_TOUCHSCREEN_GUNZE is not set +# CONFIG_TOUCHSCREEN_EKTF2127 is not set +# CONFIG_TOUCHSCREEN_ELAN is not set +# CONFIG_TOUCHSCREEN_ELO is not set +# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set +# CONFIG_TOUCHSCREEN_WACOM_I2C is not set +# CONFIG_TOUCHSCREEN_MAX11801 is not set +# CONFIG_TOUCHSCREEN_MCS5000 is not set +# CONFIG_TOUCHSCREEN_MMS114 is not set +# CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set +# CONFIG_TOUCHSCREEN_MTOUCH is not set +# CONFIG_TOUCHSCREEN_INEXIO is not set +# CONFIG_TOUCHSCREEN_MK712 is not set +# CONFIG_TOUCHSCREEN_PENMOUNT is not set +# CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set +# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set +# CONFIG_TOUCHSCREEN_TOUCHWIN is not set +# CONFIG_TOUCHSCREEN_PIXCIR is not set +# CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set +# CONFIG_TOUCHSCREEN_WM831X is not set +# CONFIG_TOUCHSCREEN_WM97XX is not set +# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set +# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set +# CONFIG_TOUCHSCREEN_TSC_SERIO is not set +# CONFIG_TOUCHSCREEN_TSC2004 is not set +# CONFIG_TOUCHSCREEN_TSC2005 is not set +# CONFIG_TOUCHSCREEN_TSC2007 is not set +# CONFIG_TOUCHSCREEN_PCAP is not set +# CONFIG_TOUCHSCREEN_RM_TS is not set +# CONFIG_TOUCHSCREEN_SILEAD is not set +# CONFIG_TOUCHSCREEN_SIS_I2C is not set +# CONFIG_TOUCHSCREEN_ST1232 is not set +# CONFIG_TOUCHSCREEN_SUR40 is not set +# CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set +# CONFIG_TOUCHSCREEN_SX8654 is not set +# CONFIG_TOUCHSCREEN_TPS6507X is not set +# CONFIG_TOUCHSCREEN_ZET6223 is not set +# CONFIG_TOUCHSCREEN_ZFORCE is not set +# CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set +CONFIG_INPUT_MISC=y +# CONFIG_INPUT_88PM860X_ONKEY is not set +# CONFIG_INPUT_AD714X is not set +# CONFIG_INPUT_BMA150 is not set +# CONFIG_INPUT_E3X0_BUTTON is not set +# CONFIG_INPUT_PCSPKR is not set +# CONFIG_INPUT_MAX77693_HAPTIC is not set +# CONFIG_INPUT_MAX8925_ONKEY is not set +# CONFIG_INPUT_MAX8997_HAPTIC is not set +# CONFIG_INPUT_MMA8450 is not set +# CONFIG_INPUT_APANEL is not set +# CONFIG_INPUT_GP2A is not set +# CONFIG_INPUT_GPIO_BEEPER is not set +# CONFIG_INPUT_GPIO_TILT_POLLED is not set +# CONFIG_INPUT_GPIO_DECODER is not set +# CONFIG_INPUT_ATLAS_BTNS is not set +# CONFIG_INPUT_ATI_REMOTE2 is not set +# CONFIG_INPUT_KEYSPAN_REMOTE is not set +# CONFIG_INPUT_KXTJ9 is not set +# CONFIG_INPUT_POWERMATE is not set +# CONFIG_INPUT_YEALINK is not set +# CONFIG_INPUT_CM109 is not set +# CONFIG_INPUT_REGULATOR_HAPTIC is not set +# CONFIG_INPUT_TWL4030_PWRBUTTON is not set +# CONFIG_INPUT_TWL4030_VIBRA is not set +# CONFIG_INPUT_TWL6040_VIBRA is not set +CONFIG_INPUT_UINPUT=y +# CONFIG_INPUT_PALMAS_PWRBUTTON is not set +# CONFIG_INPUT_PCF8574 is not set +# CONFIG_INPUT_PWM_BEEPER is not set +# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set +# CONFIG_INPUT_DA9052_ONKEY is not set +# CONFIG_INPUT_DA9055_ONKEY is not set +# CONFIG_INPUT_DA9063_ONKEY is not set +# CONFIG_INPUT_WM831X_ON is not set +# CONFIG_INPUT_PCAP is not set +# CONFIG_INPUT_ADXL34X is not set +# CONFIG_INPUT_IMS_PCU is not set +# CONFIG_INPUT_CMA3000 is not set +# CONFIG_INPUT_XEN_KBDDEV_FRONTEND is not set +# CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set +# CONFIG_INPUT_DRV260X_HAPTICS is not set +# CONFIG_INPUT_DRV2665_HAPTICS is not set +# CONFIG_INPUT_DRV2667_HAPTICS is not set +# CONFIG_RMI4_CORE is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y +CONFIG_SERIO_I8042=y +# CONFIG_SERIO_SERPORT is not set +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_PARKBD is not set +# CONFIG_SERIO_PCIPS2 is not set +CONFIG_SERIO_LIBPS2=y +CONFIG_SERIO_RAW=m +# CONFIG_SERIO_ALTERA_PS2 is not set +# CONFIG_SERIO_PS2MULT is not set +# CONFIG_SERIO_ARC_PS2 is not set +# CONFIG_USERIO is not set +CONFIG_GAMEPORT=m +# CONFIG_GAMEPORT_NS558 is not set +# CONFIG_GAMEPORT_L4 is not set +# CONFIG_GAMEPORT_EMU10K1 is not set +# CONFIG_GAMEPORT_FM801 is not set + +# +# Character devices +# +CONFIG_TTY=y +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_VT_CONSOLE_SLEEP=y +CONFIG_HW_CONSOLE=y +CONFIG_VT_HW_CONSOLE_BINDING=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=0 +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_ROCKETPORT is not set +# CONFIG_CYCLADES is not set +# CONFIG_MOXA_INTELLIO is not set +# CONFIG_MOXA_SMARTIO is not set +# CONFIG_SYNCLINK is not set +# CONFIG_SYNCLINKMP is not set +# CONFIG_SYNCLINK_GT is not set +# CONFIG_NOZOMI is not set +# CONFIG_ISI is not set +# CONFIG_N_HDLC is not set +# CONFIG_N_GSM is not set +# CONFIG_TRACE_SINK is not set +CONFIG_DEVMEM=y +# CONFIG_DEVKMEM is not set + +# +# Serial drivers +# +CONFIG_SERIAL_EARLYCON=y +CONFIG_SERIAL_8250=y +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set +CONFIG_SERIAL_8250_PNP=y +CONFIG_SERIAL_8250_FINTEK=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_DMA=y +CONFIG_SERIAL_8250_PCI=y +CONFIG_SERIAL_8250_EXAR=y +CONFIG_SERIAL_8250_NR_UARTS=48 +CONFIG_SERIAL_8250_RUNTIME_UARTS=32 +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +# CONFIG_SERIAL_8250_DETECT_IRQ is not set +CONFIG_SERIAL_8250_RSA=y +# CONFIG_SERIAL_8250_FSL is not set +# CONFIG_SERIAL_8250_DW is not set +CONFIG_SERIAL_8250_RT288X=y +CONFIG_SERIAL_8250_LPSS=y +# CONFIG_SERIAL_8250_MID is not set +# CONFIG_SERIAL_8250_MOXA is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_KGDB_NMI=y +# CONFIG_SERIAL_MAX3100 is not set +CONFIG_SERIAL_MAX310X=y +# CONFIG_SERIAL_UARTLITE is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_CONSOLE_POLL=y +# CONFIG_SERIAL_JSM is not set +CONFIG_SERIAL_SCCNXP=y +CONFIG_SERIAL_SCCNXP_CONSOLE=y +# CONFIG_SERIAL_SC16IS7XX is not set +# CONFIG_SERIAL_ALTERA_JTAGUART is not set +# CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_IFX6X60 is not set +# CONFIG_SERIAL_ARC is not set +# CONFIG_SERIAL_RP2 is not set +# CONFIG_SERIAL_FSL_LPUART is not set +# CONFIG_SERIAL_DEV_BUS is not set +CONFIG_TTY_PRINTK=y +CONFIG_PRINTER=m +# CONFIG_LP_CONSOLE is not set +CONFIG_PPDEV=m +CONFIG_HVC_DRIVER=y +CONFIG_HVC_IRQ=y +CONFIG_HVC_XEN=y +CONFIG_HVC_XEN_FRONTEND=y +CONFIG_VIRTIO_CONSOLE=y +# CONFIG_IPMI_HANDLER is not set +CONFIG_HW_RANDOM=y +# CONFIG_HW_RANDOM_TIMERIOMEM is not set +# CONFIG_HW_RANDOM_INTEL is not set +# CONFIG_HW_RANDOM_AMD is not set +# CONFIG_HW_RANDOM_VIA is not set +# CONFIG_HW_RANDOM_VIRTIO is not set +# CONFIG_HW_RANDOM_TPM is not set +# CONFIG_NVRAM is not set +# CONFIG_R3964 is not set +# CONFIG_APPLICOM is not set +# CONFIG_MWAVE is not set +# CONFIG_RAW_DRIVER is not set +CONFIG_HPET=y +CONFIG_HPET_MMAP=y +CONFIG_HPET_MMAP_DEFAULT=y +# CONFIG_HANGCHECK_TIMER is not set +CONFIG_TCG_TPM=y +CONFIG_TCG_TIS_CORE=y +CONFIG_TCG_TIS=y +# CONFIG_TCG_TIS_SPI is not set +# CONFIG_TCG_TIS_I2C_ATMEL is not set +# CONFIG_TCG_TIS_I2C_INFINEON is not set +# CONFIG_TCG_TIS_I2C_NUVOTON is not set +# CONFIG_TCG_NSC is not set +# CONFIG_TCG_ATMEL is not set +# CONFIG_TCG_INFINEON is not set +# CONFIG_TCG_XEN is not set +# CONFIG_TCG_CRB is not set +# CONFIG_TCG_VTPM_PROXY is not set +# CONFIG_TCG_TIS_ST33ZP24_I2C is not set +# CONFIG_TCG_TIS_ST33ZP24_SPI is not set +# CONFIG_TELCLOCK is not set +CONFIG_DEVPORT=y +# CONFIG_XILLYBUS is not set + +# +# I2C support +# +CONFIG_I2C=y +CONFIG_ACPI_I2C_OPREGION=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_MUX=m + +# +# Multiplexer I2C Chip support +# +# CONFIG_I2C_MUX_GPIO is not set +# CONFIG_I2C_MUX_PCA9541 is not set +# CONFIG_I2C_MUX_PCA954x is not set +# CONFIG_I2C_MUX_PINCTRL is not set +# CONFIG_I2C_MUX_REG is not set +# CONFIG_I2C_MUX_MLXCPLD is not set +CONFIG_I2C_HELPER_AUTO=y +CONFIG_I2C_ALGOBIT=m + +# +# I2C Hardware Bus support +# + +# +# PC SMBus host controller drivers +# +# CONFIG_I2C_ALI1535 is not set +# CONFIG_I2C_ALI1563 is not set +# CONFIG_I2C_ALI15X3 is not set +# CONFIG_I2C_AMD756 is not set +# CONFIG_I2C_AMD8111 is not set +# CONFIG_I2C_I801 is not set +# CONFIG_I2C_ISCH is not set +# CONFIG_I2C_ISMT is not set +CONFIG_I2C_PIIX4=m +# CONFIG_I2C_NFORCE2 is not set +# CONFIG_I2C_SIS5595 is not set +# CONFIG_I2C_SIS630 is not set +# CONFIG_I2C_SIS96X is not set +# CONFIG_I2C_VIA is not set +# CONFIG_I2C_VIAPRO is not set + +# +# ACPI drivers +# +# CONFIG_I2C_SCMI is not set + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_CBUS_GPIO is not set +# CONFIG_I2C_DESIGNWARE_PLATFORM is not set +# CONFIG_I2C_DESIGNWARE_PCI is not set +# CONFIG_I2C_EMEV2 is not set +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_PXA_PCI is not set +# CONFIG_I2C_SIMTEC is not set +# CONFIG_I2C_XILINX is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_DIOLAN_U2C is not set +# CONFIG_I2C_PARPORT is not set +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_ROBOTFUZZ_OSIF is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_MLXCPLD is not set +# CONFIG_I2C_STUB is not set +CONFIG_I2C_SLAVE=y +# CONFIG_I2C_SLAVE_EEPROM is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +CONFIG_SPI=y +# CONFIG_SPI_DEBUG is not set +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +# CONFIG_SPI_ALTERA is not set +# CONFIG_SPI_AXI_SPI_ENGINE is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_SPI_BUTTERFLY is not set +# CONFIG_SPI_CADENCE is not set +# CONFIG_SPI_DESIGNWARE is not set +# CONFIG_SPI_GPIO is not set +# CONFIG_SPI_LM70_LLP is not set +# CONFIG_SPI_OC_TINY is not set +# CONFIG_SPI_PXA2XX is not set +# CONFIG_SPI_PXA2XX_PCI is not set +# CONFIG_SPI_ROCKCHIP is not set +# CONFIG_SPI_SC18IS602 is not set +# CONFIG_SPI_XCOMM is not set +# CONFIG_SPI_XILINX is not set +# CONFIG_SPI_ZYNQMP_GQSPI is not set + +# +# SPI Protocol Masters +# +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_LOOPBACK_TEST is not set +# CONFIG_SPI_TLE62X0 is not set +# CONFIG_SPMI is not set +# CONFIG_HSI is not set + +# +# PPS support +# +# CONFIG_PPS is not set + +# +# PPS generators support +# + +# +# PTP clock support +# +# CONFIG_PTP_1588_CLOCK is not set + +# +# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. +# +CONFIG_PINCTRL=y + +# +# Pin controllers +# +CONFIG_PINMUX=y +CONFIG_PINCONF=y +CONFIG_GENERIC_PINCONF=y +# CONFIG_DEBUG_PINCTRL is not set +CONFIG_PINCTRL_AMD=y +CONFIG_PINCTRL_SX150X=y +CONFIG_PINCTRL_BAYTRAIL=y +# CONFIG_PINCTRL_CHERRYVIEW is not set +# CONFIG_PINCTRL_BROXTON is not set +# CONFIG_PINCTRL_GEMINILAKE is not set +# CONFIG_PINCTRL_SUNRISEPOINT is not set +CONFIG_GPIOLIB=y +CONFIG_GPIO_ACPI=y +CONFIG_GPIOLIB_IRQCHIP=y +# CONFIG_DEBUG_GPIO is not set +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO drivers +# +# CONFIG_GPIO_AMDPT is not set +# CONFIG_GPIO_DWAPB is not set +# CONFIG_GPIO_EXAR is not set +# CONFIG_GPIO_GENERIC_PLATFORM is not set +# CONFIG_GPIO_ICH is not set +CONFIG_GPIO_LYNXPOINT=y +# CONFIG_GPIO_MOCKUP is not set +# CONFIG_GPIO_VX855 is not set + +# +# Port-mapped I/O GPIO drivers +# +# CONFIG_GPIO_104_DIO_48E is not set +# CONFIG_GPIO_104_IDIO_16 is not set +# CONFIG_GPIO_104_IDI_48 is not set +# CONFIG_GPIO_F7188X is not set +# CONFIG_GPIO_GPIO_MM is not set +# CONFIG_GPIO_IT87 is not set +# CONFIG_GPIO_SCH is not set +# CONFIG_GPIO_SCH311X is not set +# CONFIG_GPIO_WS16C48 is not set + +# +# I2C GPIO expanders +# +# CONFIG_GPIO_ADP5588 is not set +# CONFIG_GPIO_MAX7300 is not set +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set +CONFIG_GPIO_SX150X=y +# CONFIG_GPIO_TPIC2810 is not set + +# +# MFD GPIO expanders +# +# CONFIG_GPIO_ADP5520 is not set +# CONFIG_GPIO_CRYSTAL_COVE is not set +# CONFIG_GPIO_DA9052 is not set +# CONFIG_GPIO_DA9055 is not set +CONFIG_GPIO_PALMAS=y +CONFIG_GPIO_RC5T583=y +CONFIG_GPIO_TPS6586X=y +CONFIG_GPIO_TPS65910=y +# CONFIG_GPIO_TPS65912 is not set +# CONFIG_GPIO_TWL4030 is not set +# CONFIG_GPIO_TWL6040 is not set +# CONFIG_GPIO_WHISKEY_COVE is not set +# CONFIG_GPIO_WM831X is not set +# CONFIG_GPIO_WM8350 is not set + +# +# PCI GPIO expanders +# +# CONFIG_GPIO_AMD8111 is not set +# CONFIG_GPIO_BT8XX is not set +# CONFIG_GPIO_ML_IOH is not set +# CONFIG_GPIO_PCI_IDIO_16 is not set +# CONFIG_GPIO_RDC321X is not set + +# +# SPI GPIO expanders +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MC33880 is not set +# CONFIG_GPIO_PISOSR is not set + +# +# SPI or I2C GPIO expanders +# + +# +# USB GPIO expanders +# +# CONFIG_W1 is not set +CONFIG_POWER_AVS=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_RESTART=y +CONFIG_POWER_SUPPLY=y +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_PDA_POWER is not set +# CONFIG_MAX8925_POWER is not set +# CONFIG_WM831X_BACKUP is not set +# CONFIG_WM831X_POWER is not set +# CONFIG_WM8350_POWER is not set +# CONFIG_TEST_POWER is not set +# CONFIG_BATTERY_88PM860X is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2781 is not set +# CONFIG_BATTERY_DS2782 is not set +# CONFIG_BATTERY_SBS is not set +# CONFIG_CHARGER_SBS is not set +# CONFIG_BATTERY_BQ27XXX is not set +# CONFIG_BATTERY_DA9030 is not set +# CONFIG_BATTERY_DA9052 is not set +# CONFIG_BATTERY_MAX17040 is not set +# CONFIG_BATTERY_MAX17042 is not set +# CONFIG_CHARGER_MAX8903 is not set +# CONFIG_CHARGER_LP8727 is not set +# CONFIG_CHARGER_GPIO is not set +CONFIG_CHARGER_MANAGER=y +# CONFIG_CHARGER_MAX14577 is not set +# CONFIG_CHARGER_MAX77693 is not set +# CONFIG_CHARGER_BQ2415X is not set +# CONFIG_CHARGER_BQ24190 is not set +# CONFIG_CHARGER_BQ24257 is not set +# CONFIG_CHARGER_BQ24735 is not set +# CONFIG_CHARGER_BQ25890 is not set +# CONFIG_CHARGER_SMB347 is not set +# CONFIG_CHARGER_TPS65090 is not set +# CONFIG_BATTERY_GAUGE_LTC2941 is not set +# CONFIG_CHARGER_RT9455 is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_HWMON_DEBUG_CHIP is not set + +# +# Native drivers +# +# CONFIG_SENSORS_ABITUGURU is not set +# CONFIG_SENSORS_ABITUGURU3 is not set +# CONFIG_SENSORS_AD7314 is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7310 is not set +# CONFIG_SENSORS_ADT7410 is not set +# CONFIG_SENSORS_ADT7411 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7475 is not set +# CONFIG_SENSORS_ASC7621 is not set +# CONFIG_SENSORS_K8TEMP is not set +# CONFIG_SENSORS_K10TEMP is not set +# CONFIG_SENSORS_FAM15H_POWER is not set +# CONFIG_SENSORS_APPLESMC is not set +# CONFIG_SENSORS_ASB100 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS620 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_DELL_SMM is not set +# CONFIG_SENSORS_DA9052_ADC is not set +# CONFIG_SENSORS_DA9055 is not set +# CONFIG_SENSORS_I5K_AMB is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_FSCHMD is not set +# CONFIG_SENSORS_FTSTEUTATES is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_G760A is not set +# CONFIG_SENSORS_G762 is not set +# CONFIG_SENSORS_GPIO_FAN is not set +# CONFIG_SENSORS_HIH6130 is not set +# CONFIG_SENSORS_I5500 is not set +CONFIG_SENSORS_CORETEMP=m +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_JC42 is not set +# CONFIG_SENSORS_POWR1220 is not set +# CONFIG_SENSORS_LINEAGE is not set +# CONFIG_SENSORS_LTC2945 is not set +# CONFIG_SENSORS_LTC2990 is not set +# CONFIG_SENSORS_LTC4151 is not set +# CONFIG_SENSORS_LTC4215 is not set +# CONFIG_SENSORS_LTC4222 is not set +# CONFIG_SENSORS_LTC4245 is not set +# CONFIG_SENSORS_LTC4260 is not set +# CONFIG_SENSORS_LTC4261 is not set +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX16065 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX1668 is not set +# CONFIG_SENSORS_MAX197 is not set +# CONFIG_SENSORS_MAX31722 is not set +# CONFIG_SENSORS_MAX6639 is not set +# CONFIG_SENSORS_MAX6642 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_MAX6697 is not set +# CONFIG_SENSORS_MAX31790 is not set +# CONFIG_SENSORS_MCP3021 is not set +# CONFIG_SENSORS_TC654 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +# CONFIG_SENSORS_LM73 is not set +# CONFIG_SENSORS_LM75 is not set +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +# CONFIG_SENSORS_LM95234 is not set +# CONFIG_SENSORS_LM95241 is not set +# CONFIG_SENSORS_LM95245 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_NTC_THERMISTOR is not set +# CONFIG_SENSORS_NCT6683 is not set +# CONFIG_SENSORS_NCT6775 is not set +# CONFIG_SENSORS_NCT7802 is not set +# CONFIG_SENSORS_NCT7904 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_PMBUS is not set +# CONFIG_SENSORS_SHT15 is not set +# CONFIG_SENSORS_SHT21 is not set +# CONFIG_SENSORS_SHT3x is not set +# CONFIG_SENSORS_SHTC1 is not set +# CONFIG_SENSORS_SIS5595 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_EMC1403 is not set +# CONFIG_SENSORS_EMC2103 is not set +# CONFIG_SENSORS_EMC6W201 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +# CONFIG_SENSORS_SCH56XX_COMMON is not set +# CONFIG_SENSORS_SCH5627 is not set +# CONFIG_SENSORS_SCH5636 is not set +# CONFIG_SENSORS_STTS751 is not set +# CONFIG_SENSORS_SMM665 is not set +# CONFIG_SENSORS_ADC128D818 is not set +# CONFIG_SENSORS_ADS1015 is not set +# CONFIG_SENSORS_ADS7828 is not set +# CONFIG_SENSORS_ADS7871 is not set +# CONFIG_SENSORS_AMC6821 is not set +# CONFIG_SENSORS_INA209 is not set +# CONFIG_SENSORS_INA2XX is not set +# CONFIG_SENSORS_INA3221 is not set +# CONFIG_SENSORS_TC74 is not set +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_TMP102 is not set +# CONFIG_SENSORS_TMP103 is not set +# CONFIG_SENSORS_TMP108 is not set +# CONFIG_SENSORS_TMP401 is not set +# CONFIG_SENSORS_TMP421 is not set +# CONFIG_SENSORS_VIA_CPUTEMP is not set +# CONFIG_SENSORS_VIA686A is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_VT8231 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83795 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +# CONFIG_SENSORS_WM831X is not set +# CONFIG_SENSORS_WM8350 is not set +# CONFIG_SENSORS_XGENE is not set + +# +# ACPI drivers +# +# CONFIG_SENSORS_ACPI_POWER is not set +# CONFIG_SENSORS_ATK0110 is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_WRITABLE_TRIPS=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set +# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set +# CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set +CONFIG_THERMAL_GOV_FAIR_SHARE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_BANG_BANG=y +CONFIG_THERMAL_GOV_USER_SPACE=y +CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y +CONFIG_THERMAL_EMULATION=y +# CONFIG_INTEL_POWERCLAMP is not set +# CONFIG_X86_PKG_TEMP_THERMAL is not set +# CONFIG_INTEL_SOC_DTS_THERMAL is not set + +# +# ACPI INT340X thermal drivers +# +# CONFIG_INT340X_THERMAL is not set +# CONFIG_INTEL_BXT_PMIC_THERMAL is not set +# CONFIG_INTEL_PCH_THERMAL is not set +CONFIG_WATCHDOG=y +CONFIG_WATCHDOG_CORE=y +# CONFIG_WATCHDOG_NOWAYOUT is not set +CONFIG_WATCHDOG_SYSFS=y + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +# CONFIG_DA9052_WATCHDOG is not set +# CONFIG_DA9055_WATCHDOG is not set +# CONFIG_DA9063_WATCHDOG is not set +# CONFIG_WDAT_WDT is not set +# CONFIG_WM831X_WATCHDOG is not set +# CONFIG_WM8350_WATCHDOG is not set +# CONFIG_XILINX_WATCHDOG is not set +# CONFIG_ZIIRAVE_WATCHDOG is not set +# CONFIG_CADENCE_WATCHDOG is not set +# CONFIG_DW_WATCHDOG is not set +# CONFIG_TWL4030_WATCHDOG is not set +# CONFIG_MAX63XX_WATCHDOG is not set +# CONFIG_ACQUIRE_WDT is not set +# CONFIG_ADVANTECH_WDT is not set +# CONFIG_ALIM1535_WDT is not set +# CONFIG_ALIM7101_WDT is not set +# CONFIG_EBC_C384_WDT is not set +# CONFIG_F71808E_WDT is not set +# CONFIG_SP5100_TCO is not set +# CONFIG_SBC_FITPC2_WATCHDOG is not set +# CONFIG_EUROTECH_WDT is not set +# CONFIG_IB700_WDT is not set +# CONFIG_IBMASR is not set +# CONFIG_WAFER_WDT is not set +# CONFIG_I6300ESB_WDT is not set +# CONFIG_IE6XX_WDT is not set +# CONFIG_ITCO_WDT is not set +# CONFIG_IT8712F_WDT is not set +# CONFIG_IT87_WDT is not set +# CONFIG_HP_WATCHDOG is not set +# CONFIG_SC1200_WDT is not set +# CONFIG_PC87413_WDT is not set +# CONFIG_NV_TCO is not set +# CONFIG_60XX_WDT is not set +# CONFIG_CPU5_WDT is not set +# CONFIG_SMSC_SCH311X_WDT is not set +# CONFIG_SMSC37B787_WDT is not set +# CONFIG_VIA_WDT is not set +# CONFIG_W83627HF_WDT is not set +# CONFIG_W83877F_WDT is not set +# CONFIG_W83977F_WDT is not set +# CONFIG_MACHZ_WDT is not set +# CONFIG_SBC_EPX_C3_WATCHDOG is not set +# CONFIG_NI903X_WDT is not set +# CONFIG_NIC7018_WDT is not set +# CONFIG_MEN_A21_WDT is not set +# CONFIG_XEN_WDT is not set + +# +# PCI-based Watchdog Cards +# +# CONFIG_PCIPCWATCHDOG is not set +# CONFIG_WDTPCI is not set + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set + +# +# Watchdog Pretimeout Governors +# +# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set +CONFIG_BCMA_POSSIBLE=y + +# +# Broadcom specific AMBA +# +# CONFIG_BCMA is not set + +# +# Multifunction device drivers +# +CONFIG_MFD_CORE=y +CONFIG_MFD_AS3711=y +CONFIG_PMIC_ADP5520=y +CONFIG_MFD_AAT2870_CORE=y +# CONFIG_MFD_BCM590XX is not set +# CONFIG_MFD_AXP20X_I2C is not set +# CONFIG_MFD_CROS_EC is not set +CONFIG_PMIC_DA903X=y +CONFIG_PMIC_DA9052=y +CONFIG_MFD_DA9052_SPI=y +CONFIG_MFD_DA9052_I2C=y +CONFIG_MFD_DA9055=y +# CONFIG_MFD_DA9062 is not set +CONFIG_MFD_DA9063=y +# CONFIG_MFD_DA9150 is not set +# CONFIG_MFD_DLN2 is not set +# CONFIG_MFD_MC13XXX_SPI is not set +# CONFIG_MFD_MC13XXX_I2C is not set +# CONFIG_HTC_PASIC3 is not set +CONFIG_HTC_I2CPLD=y +# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set +# CONFIG_LPC_ICH is not set +# CONFIG_LPC_SCH is not set +CONFIG_INTEL_SOC_PMIC=y +# CONFIG_MFD_INTEL_LPSS_ACPI is not set +# CONFIG_MFD_INTEL_LPSS_PCI is not set +# CONFIG_MFD_JANZ_CMODIO is not set +# CONFIG_MFD_KEMPLD is not set +# CONFIG_MFD_88PM800 is not set +# CONFIG_MFD_88PM805 is not set +CONFIG_MFD_88PM860X=y +CONFIG_MFD_MAX14577=y +CONFIG_MFD_MAX77693=y +CONFIG_MFD_MAX77843=y +# CONFIG_MFD_MAX8907 is not set +CONFIG_MFD_MAX8925=y +CONFIG_MFD_MAX8997=y +CONFIG_MFD_MAX8998=y +# CONFIG_MFD_MT6397 is not set +# CONFIG_MFD_MENF21BMC is not set +CONFIG_EZX_PCAP=y +# CONFIG_MFD_VIPERBOARD is not set +# CONFIG_MFD_RETU is not set +# CONFIG_MFD_PCF50633 is not set +# CONFIG_UCB1400_CORE is not set +# CONFIG_MFD_RDC321X is not set +# CONFIG_MFD_RTSX_PCI is not set +# CONFIG_MFD_RT5033 is not set +# CONFIG_MFD_RTSX_USB is not set +CONFIG_MFD_RC5T583=y +CONFIG_MFD_SEC_CORE=y +# CONFIG_MFD_SI476X_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_SKY81452 is not set +CONFIG_MFD_SMSC=y +CONFIG_ABX500_CORE=y +CONFIG_AB3100_CORE=y +# CONFIG_AB3100_OTP is not set +CONFIG_MFD_SYSCON=y +# CONFIG_MFD_TI_AM335X_TSCADC is not set +# CONFIG_MFD_LP3943 is not set +CONFIG_MFD_LP8788=y +CONFIG_MFD_PALMAS=y +# CONFIG_TPS6105X is not set +# CONFIG_TPS65010 is not set +# CONFIG_TPS6507X is not set +# CONFIG_MFD_TPS65086 is not set +CONFIG_MFD_TPS65090=y +# CONFIG_MFD_TPS65217 is not set +# CONFIG_MFD_TI_LP873X is not set +# CONFIG_MFD_TPS65218 is not set +CONFIG_MFD_TPS6586X=y +CONFIG_MFD_TPS65910=y +CONFIG_MFD_TPS65912=y +CONFIG_MFD_TPS65912_I2C=y +CONFIG_MFD_TPS65912_SPI=y +CONFIG_MFD_TPS80031=y +CONFIG_TWL4030_CORE=y +CONFIG_MFD_TWL4030_AUDIO=y +CONFIG_TWL6040_CORE=y +# CONFIG_MFD_WL1273_CORE is not set +# CONFIG_MFD_LM3533 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_VX855 is not set +# CONFIG_MFD_ARIZONA_I2C is not set +# CONFIG_MFD_ARIZONA_SPI is not set +CONFIG_MFD_WM8400=y +CONFIG_MFD_WM831X=y +CONFIG_MFD_WM831X_I2C=y +CONFIG_MFD_WM831X_SPI=y +CONFIG_MFD_WM8350=y +CONFIG_MFD_WM8350_I2C=y +# CONFIG_MFD_WM8994 is not set +CONFIG_REGULATOR=y +# CONFIG_REGULATOR_DEBUG is not set +# CONFIG_REGULATOR_FIXED_VOLTAGE is not set +# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set +# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set +# CONFIG_REGULATOR_88PM8607 is not set +# CONFIG_REGULATOR_ACT8865 is not set +# CONFIG_REGULATOR_AD5398 is not set +# CONFIG_REGULATOR_ANATOP is not set +# CONFIG_REGULATOR_AAT2870 is not set +# CONFIG_REGULATOR_AB3100 is not set +# CONFIG_REGULATOR_AS3711 is not set +# CONFIG_REGULATOR_DA903X is not set +# CONFIG_REGULATOR_DA9052 is not set +# CONFIG_REGULATOR_DA9055 is not set +# CONFIG_REGULATOR_DA9063 is not set +# CONFIG_REGULATOR_DA9210 is not set +# CONFIG_REGULATOR_DA9211 is not set +# CONFIG_REGULATOR_FAN53555 is not set +# CONFIG_REGULATOR_GPIO is not set +# CONFIG_REGULATOR_ISL9305 is not set +# CONFIG_REGULATOR_ISL6271A is not set +# CONFIG_REGULATOR_LP3971 is not set +# CONFIG_REGULATOR_LP3972 is not set +# CONFIG_REGULATOR_LP872X is not set +# CONFIG_REGULATOR_LP8755 is not set +# CONFIG_REGULATOR_LP8788 is not set +# CONFIG_REGULATOR_LTC3589 is not set +# CONFIG_REGULATOR_LTC3676 is not set +# CONFIG_REGULATOR_MAX14577 is not set +# CONFIG_REGULATOR_MAX1586 is not set +# CONFIG_REGULATOR_MAX8649 is not set +# CONFIG_REGULATOR_MAX8660 is not set +# CONFIG_REGULATOR_MAX8925 is not set +# CONFIG_REGULATOR_MAX8952 is not set +# CONFIG_REGULATOR_MAX8997 is not set +# CONFIG_REGULATOR_MAX8998 is not set +# CONFIG_REGULATOR_MAX77693 is not set +# CONFIG_REGULATOR_MT6311 is not set +# CONFIG_REGULATOR_PALMAS is not set +# CONFIG_REGULATOR_PCAP is not set +# CONFIG_REGULATOR_PFUZE100 is not set +# CONFIG_REGULATOR_PV88060 is not set +# CONFIG_REGULATOR_PV88080 is not set +# CONFIG_REGULATOR_PV88090 is not set +# CONFIG_REGULATOR_PWM is not set +# CONFIG_REGULATOR_RC5T583 is not set +# CONFIG_REGULATOR_S2MPA01 is not set +# CONFIG_REGULATOR_S2MPS11 is not set +# CONFIG_REGULATOR_S5M8767 is not set +# CONFIG_REGULATOR_TPS51632 is not set +# CONFIG_REGULATOR_TPS62360 is not set +# CONFIG_REGULATOR_TPS65023 is not set +# CONFIG_REGULATOR_TPS6507X is not set +# CONFIG_REGULATOR_TPS65090 is not set +# CONFIG_REGULATOR_TPS6524X is not set +# CONFIG_REGULATOR_TPS6586X is not set +# CONFIG_REGULATOR_TPS65910 is not set +# CONFIG_REGULATOR_TPS65912 is not set +# CONFIG_REGULATOR_TPS80031 is not set +# CONFIG_REGULATOR_TWL4030 is not set +# CONFIG_REGULATOR_WM831X is not set +# CONFIG_REGULATOR_WM8350 is not set +# CONFIG_REGULATOR_WM8400 is not set +CONFIG_MEDIA_SUPPORT=m + +# +# Multimedia core support +# +CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_ANALOG_TV_SUPPORT=y +CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y +CONFIG_MEDIA_RADIO_SUPPORT=y +CONFIG_MEDIA_SDR_SUPPORT=y +CONFIG_MEDIA_RC_SUPPORT=y +# CONFIG_MEDIA_CEC_SUPPORT is not set +CONFIG_MEDIA_CONTROLLER=y +# CONFIG_MEDIA_CONTROLLER_DVB is not set +CONFIG_VIDEO_DEV=m +CONFIG_VIDEO_V4L2_SUBDEV_API=y +CONFIG_VIDEO_V4L2=m +# CONFIG_VIDEO_ADV_DEBUG is not set +# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set +CONFIG_VIDEOBUF2_CORE=m +CONFIG_VIDEOBUF2_MEMOPS=m +CONFIG_VIDEOBUF2_VMALLOC=m +CONFIG_DVB_CORE=m +CONFIG_DVB_NET=y +# CONFIG_TTPCI_EEPROM is not set +CONFIG_DVB_MAX_ADAPTERS=8 +CONFIG_DVB_DYNAMIC_MINORS=y +# CONFIG_DVB_DEMUX_SECTION_LOSS_LOG is not set + +# +# Media drivers +# +CONFIG_RC_CORE=m +# CONFIG_RC_MAP is not set +CONFIG_RC_DECODERS=y +# CONFIG_LIRC is not set +# CONFIG_IR_NEC_DECODER is not set +# CONFIG_IR_RC5_DECODER is not set +# CONFIG_IR_RC6_DECODER is not set +# CONFIG_IR_JVC_DECODER is not set +# CONFIG_IR_SONY_DECODER is not set +# CONFIG_IR_SANYO_DECODER is not set +# CONFIG_IR_SHARP_DECODER is not set +# CONFIG_IR_MCE_KBD_DECODER is not set +# CONFIG_IR_XMP_DECODER is not set +CONFIG_RC_DEVICES=y +# CONFIG_RC_ATI_REMOTE is not set +# CONFIG_IR_ENE is not set +# CONFIG_IR_HIX5HD2 is not set +# CONFIG_IR_IMON is not set +# CONFIG_IR_MCEUSB is not set +# CONFIG_IR_ITE_CIR is not set +# CONFIG_IR_FINTEK is not set +# CONFIG_IR_NUVOTON is not set +# CONFIG_IR_REDRAT3 is not set +# CONFIG_IR_STREAMZAP is not set +# CONFIG_IR_WINBOND_CIR is not set +# CONFIG_IR_IGORPLUGUSB is not set +# CONFIG_IR_IGUANA is not set +# CONFIG_IR_TTUSBIR is not set +# CONFIG_RC_LOOPBACK is not set +# CONFIG_IR_GPIO_CIR is not set +# CONFIG_IR_SERIAL is not set +CONFIG_MEDIA_USB_SUPPORT=y + +# +# Webcam devices +# +CONFIG_USB_VIDEO_CLASS=m +CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y +# CONFIG_USB_GSPCA is not set +# CONFIG_USB_PWC is not set +# CONFIG_VIDEO_CPIA2 is not set +# CONFIG_USB_ZR364XX is not set +# CONFIG_USB_STKWEBCAM is not set +# CONFIG_USB_S2255 is not set +# CONFIG_VIDEO_USBTV is not set + +# +# Analog TV USB devices +# +# CONFIG_VIDEO_PVRUSB2 is not set +# CONFIG_VIDEO_HDPVR is not set +# CONFIG_VIDEO_USBVISION is not set +# CONFIG_VIDEO_STK1160_COMMON is not set +# CONFIG_VIDEO_GO7007 is not set + +# +# Analog/digital TV USB devices +# +# CONFIG_VIDEO_AU0828 is not set +# CONFIG_VIDEO_CX231XX is not set +# CONFIG_VIDEO_TM6000 is not set + +# +# Digital TV USB devices +# +# CONFIG_DVB_USB is not set +# CONFIG_DVB_USB_V2 is not set +# CONFIG_DVB_TTUSB_BUDGET is not set +# CONFIG_DVB_TTUSB_DEC is not set +# CONFIG_SMS_USB_DRV is not set +# CONFIG_DVB_B2C2_FLEXCOP_USB is not set +# CONFIG_DVB_AS102 is not set + +# +# Webcam, TV (analog/digital) USB devices +# +# CONFIG_VIDEO_EM28XX is not set + +# +# Software defined radio USB devices +# +# CONFIG_USB_AIRSPY is not set +# CONFIG_USB_HACKRF is not set +# CONFIG_USB_MSI2500 is not set +CONFIG_MEDIA_PCI_SUPPORT=y + +# +# Media capture support +# +# CONFIG_VIDEO_SOLO6X10 is not set +# CONFIG_VIDEO_TW5864 is not set +# CONFIG_VIDEO_TW68 is not set +# CONFIG_VIDEO_TW686X is not set +# CONFIG_VIDEO_ZORAN is not set + +# +# Media capture/analog TV support +# +# CONFIG_VIDEO_IVTV is not set +# CONFIG_VIDEO_HEXIUM_GEMINI is not set +# CONFIG_VIDEO_HEXIUM_ORION is not set +# CONFIG_VIDEO_MXB is not set +# CONFIG_VIDEO_DT3155 is not set + +# +# Media capture/analog/hybrid TV support +# +# CONFIG_VIDEO_CX18 is not set +# CONFIG_VIDEO_CX23885 is not set +# CONFIG_VIDEO_CX25821 is not set +# CONFIG_VIDEO_CX88 is not set +# CONFIG_VIDEO_BT848 is not set +# CONFIG_VIDEO_SAA7134 is not set +# CONFIG_VIDEO_SAA7164 is not set + +# +# Media digital TV PCI Adapters +# +# CONFIG_DVB_AV7110 is not set +# CONFIG_DVB_BUDGET_CORE is not set +# CONFIG_DVB_B2C2_FLEXCOP_PCI is not set +# CONFIG_DVB_PLUTO2 is not set +# CONFIG_DVB_DM1105 is not set +# CONFIG_DVB_PT1 is not set +# CONFIG_DVB_PT3 is not set +# CONFIG_MANTIS_CORE is not set +# CONFIG_DVB_NGENE is not set +# CONFIG_DVB_DDBRIDGE is not set +# CONFIG_DVB_SMIPCIE is not set +# CONFIG_DVB_NETUP_UNIDVB is not set +CONFIG_V4L_PLATFORM_DRIVERS=y +# CONFIG_VIDEO_CAFE_CCIC is not set +# CONFIG_SOC_CAMERA is not set +CONFIG_V4L_MEM2MEM_DRIVERS=y +# CONFIG_VIDEO_MEM2MEM_DEINTERLACE is not set +# CONFIG_VIDEO_SH_VEU is not set +CONFIG_V4L_TEST_DRIVERS=y +# CONFIG_VIDEO_VIVID is not set +# CONFIG_VIDEO_VIM2M is not set +CONFIG_DVB_PLATFORM_DRIVERS=y + +# +# Supported MMC/SDIO adapters +# +# CONFIG_SMS_SDIO_DRV is not set +CONFIG_RADIO_ADAPTERS=y +CONFIG_RADIO_SI470X=y +# CONFIG_USB_SI470X is not set +# CONFIG_I2C_SI470X is not set +# CONFIG_RADIO_SI4713 is not set +# CONFIG_USB_MR800 is not set +# CONFIG_USB_DSBR is not set +# CONFIG_RADIO_MAXIRADIO is not set +# CONFIG_RADIO_SHARK is not set +# CONFIG_RADIO_SHARK2 is not set +# CONFIG_USB_KEENE is not set +# CONFIG_USB_RAREMONO is not set +# CONFIG_USB_MA901 is not set +# CONFIG_RADIO_TEA5764 is not set +# CONFIG_RADIO_SAA7706H is not set +# CONFIG_RADIO_TEF6862 is not set +# CONFIG_RADIO_WL1273 is not set + +# +# Texas Instruments WL128x FM driver (ST based) +# +# CONFIG_CYPRESS_FIRMWARE is not set + +# +# Media ancillary drivers (tuners, sensors, i2c, spi, frontends) +# +CONFIG_MEDIA_SUBDRV_AUTOSELECT=y +CONFIG_MEDIA_ATTACH=y +CONFIG_VIDEO_IR_I2C=m + +# +# Audio decoders, processors and mixers +# + +# +# RDS decoders +# + +# +# Video decoders +# + +# +# Video and audio decoders +# + +# +# Video encoders +# + +# +# Camera sensor devices +# + +# +# Flash devices +# + +# +# Video improvement chips +# + +# +# Audio/Video compression chips +# + +# +# Miscellaneous helper chips +# + +# +# Sensors used on soc_camera driver +# +CONFIG_MEDIA_TUNER=m +CONFIG_MEDIA_TUNER_SIMPLE=m +CONFIG_MEDIA_TUNER_TDA8290=m +CONFIG_MEDIA_TUNER_TDA827X=m +CONFIG_MEDIA_TUNER_TDA18271=m +CONFIG_MEDIA_TUNER_TDA9887=m +CONFIG_MEDIA_TUNER_TEA5761=m +CONFIG_MEDIA_TUNER_TEA5767=m +CONFIG_MEDIA_TUNER_MT20XX=m +CONFIG_MEDIA_TUNER_XC2028=m +CONFIG_MEDIA_TUNER_XC5000=m +CONFIG_MEDIA_TUNER_XC4000=m +CONFIG_MEDIA_TUNER_MC44S803=m + +# +# Multistandard (satellite) frontends +# + +# +# Multistandard (cable + terrestrial) frontends +# + +# +# DVB-S (satellite) frontends +# + +# +# DVB-T (terrestrial) frontends +# +# CONFIG_DVB_AS102_FE is not set +# CONFIG_DVB_GP8PSK_FE is not set + +# +# DVB-C (cable) frontends +# + +# +# ATSC (North American/Korean Terrestrial/Cable DTV) frontends +# + +# +# ISDB-T (terrestrial) frontends +# + +# +# ISDB-S (satellite) & ISDB-T (terrestrial) frontends +# + +# +# Digital terrestrial only tuners/PLL +# + +# +# SEC control devices for DVB-S +# + +# +# Tools to develop new frontends +# +# CONFIG_DVB_DUMMY_FE is not set + +# +# Graphics support +# +CONFIG_AGP=y +CONFIG_AGP_AMD64=y +CONFIG_AGP_INTEL=y +# CONFIG_AGP_SIS is not set +CONFIG_AGP_VIA=y +CONFIG_INTEL_GTT=y +CONFIG_VGA_ARB=y +CONFIG_VGA_ARB_MAX_GPUS=16 +CONFIG_VGA_SWITCHEROO=y +CONFIG_DRM=m +CONFIG_DRM_DP_AUX_CHARDEV=y +# CONFIG_DRM_DEBUG_MM_SELFTEST is not set +CONFIG_DRM_KMS_HELPER=m +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_FBDEV_EMULATION=y +CONFIG_DRM_LOAD_EDID_FIRMWARE=y +CONFIG_DRM_TTM=m + +# +# I2C encoder or helper chips +# +# CONFIG_DRM_I2C_CH7006 is not set +# CONFIG_DRM_I2C_SIL164 is not set +# CONFIG_DRM_I2C_NXP_TDA998X is not set +# CONFIG_DRM_RADEON is not set +# CONFIG_DRM_AMDGPU is not set + +# +# ACP (Audio CoProcessor) Configuration +# +# CONFIG_DRM_NOUVEAU is not set +# CONFIG_DRM_I915 is not set +# CONFIG_DRM_VGEM is not set +CONFIG_DRM_VMWGFX=m +CONFIG_DRM_VMWGFX_FBCON=y +# CONFIG_DRM_GMA500 is not set +# CONFIG_DRM_UDL is not set +# CONFIG_DRM_AST is not set +# CONFIG_DRM_MGAG200 is not set +# CONFIG_DRM_CIRRUS_QEMU is not set +# CONFIG_DRM_QXL is not set +# CONFIG_DRM_BOCHS is not set +# CONFIG_DRM_VIRTIO_GPU is not set +CONFIG_DRM_BRIDGE=y + +# +# Display Interface Bridges +# +# CONFIG_DRM_ANALOGIX_ANX78XX is not set +# CONFIG_DRM_HISI_HIBMC is not set +# CONFIG_DRM_TINYDRM is not set +# CONFIG_DRM_LEGACY is not set +# CONFIG_DRM_LIB_RANDOM is not set + +# +# Frame buffer Devices +# +CONFIG_FB=y +CONFIG_FIRMWARE_EDID=y +CONFIG_FB_CMDLINE=y +CONFIG_FB_NOTIFY=y +# CONFIG_FB_DDC is not set +CONFIG_FB_BOOT_VESA_SUPPORT=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_IMAGEBLIT=y +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set +CONFIG_FB_SYS_FILLRECT=m +CONFIG_FB_SYS_COPYAREA=m +CONFIG_FB_SYS_IMAGEBLIT=m +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set +# CONFIG_FB_FOREIGN_ENDIAN is not set +CONFIG_FB_SYS_FOPS=m +CONFIG_FB_DEFERRED_IO=y +# CONFIG_FB_SVGALIB is not set +# CONFIG_FB_MACMODES is not set +# CONFIG_FB_BACKLIGHT is not set +CONFIG_FB_MODE_HELPERS=y +CONFIG_FB_TILEBLITTING=y + +# +# Frame buffer hardware drivers +# +# CONFIG_FB_CIRRUS is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set +# CONFIG_FB_ARC is not set +CONFIG_FB_ASILIANT=y +CONFIG_FB_IMSTT=y +# CONFIG_FB_VGA16 is not set +# CONFIG_FB_UVESA is not set +CONFIG_FB_VESA=y +CONFIG_FB_EFI=y +# CONFIG_FB_N411 is not set +# CONFIG_FB_HGA is not set +# CONFIG_FB_OPENCORES is not set +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_NVIDIA is not set +# CONFIG_FB_RIVA is not set +# CONFIG_FB_I740 is not set +# CONFIG_FB_LE80578 is not set +# CONFIG_FB_INTEL is not set +# CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON is not set +# CONFIG_FB_ATY128 is not set +# CONFIG_FB_ATY is not set +# CONFIG_FB_S3 is not set +# CONFIG_FB_SAVAGE is not set +# CONFIG_FB_SIS is not set +# CONFIG_FB_VIA is not set +# CONFIG_FB_NEOMAGIC is not set +# CONFIG_FB_KYRO is not set +# CONFIG_FB_3DFX is not set +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VT8623 is not set +# CONFIG_FB_TRIDENT is not set +# CONFIG_FB_ARK is not set +# CONFIG_FB_PM3 is not set +# CONFIG_FB_CARMINE is not set +# CONFIG_FB_SMSCUFX is not set +# CONFIG_FB_UDL is not set +# CONFIG_FB_IBM_GXT4500 is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_XEN_FBDEV_FRONTEND is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_BROADSHEET is not set +# CONFIG_FB_AUO_K190X is not set +CONFIG_FB_SIMPLE=y +# CONFIG_FB_SM712 is not set +CONFIG_BACKLIGHT_LCD_SUPPORT=y +# CONFIG_LCD_CLASS_DEVICE is not set +CONFIG_BACKLIGHT_CLASS_DEVICE=y +# CONFIG_BACKLIGHT_GENERIC is not set +# CONFIG_BACKLIGHT_PWM is not set +# CONFIG_BACKLIGHT_DA903X is not set +# CONFIG_BACKLIGHT_DA9052 is not set +# CONFIG_BACKLIGHT_MAX8925 is not set +# CONFIG_BACKLIGHT_APPLE is not set +# CONFIG_BACKLIGHT_PM8941_WLED is not set +# CONFIG_BACKLIGHT_SAHARA is not set +# CONFIG_BACKLIGHT_WM831X is not set +# CONFIG_BACKLIGHT_ADP5520 is not set +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set +# CONFIG_BACKLIGHT_88PM860X is not set +# CONFIG_BACKLIGHT_AAT2870 is not set +# CONFIG_BACKLIGHT_LM3630A is not set +# CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_LP855X is not set +# CONFIG_BACKLIGHT_LP8788 is not set +# CONFIG_BACKLIGHT_PANDORA is not set +# CONFIG_BACKLIGHT_AS3711 is not set +# CONFIG_BACKLIGHT_GPIO is not set +# CONFIG_BACKLIGHT_LV5207LP is not set +# CONFIG_BACKLIGHT_BD6107 is not set +# CONFIG_VGASTATE is not set +CONFIG_HDMI=y + +# +# Console display driver support +# +CONFIG_VGA_CONSOLE=y +# CONFIG_VGACON_SOFT_SCROLLBACK is not set +CONFIG_DUMMY_CONSOLE=y +CONFIG_DUMMY_CONSOLE_COLUMNS=80 +CONFIG_DUMMY_CONSOLE_ROWS=25 +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +# CONFIG_LOGO is not set +CONFIG_SOUND=m +# CONFIG_SOUND_OSS_CORE is not set +CONFIG_SND=m +CONFIG_SND_TIMER=m +CONFIG_SND_PCM=m +CONFIG_SND_HWDEP=m +CONFIG_SND_RAWMIDI=m +CONFIG_SND_SEQUENCER=m +# CONFIG_SND_SEQ_DUMMY is not set +# CONFIG_SND_MIXER_OSS is not set +# CONFIG_SND_PCM_OSS is not set +CONFIG_SND_PCM_TIMER=y +# CONFIG_SND_SEQUENCER_OSS is not set +# CONFIG_SND_HRTIMER is not set +CONFIG_SND_DYNAMIC_MINORS=y +CONFIG_SND_MAX_CARDS=32 +CONFIG_SND_SUPPORT_OLD_API=y +CONFIG_SND_PROC_FS=y +CONFIG_SND_VERBOSE_PROCFS=y +# CONFIG_SND_VERBOSE_PRINTK is not set +# CONFIG_SND_DEBUG is not set +CONFIG_SND_VMASTER=y +CONFIG_SND_DMA_SGBUF=y +CONFIG_SND_RAWMIDI_SEQ=m +CONFIG_SND_OPL3_LIB_SEQ=m +# CONFIG_SND_OPL4_LIB_SEQ is not set +# CONFIG_SND_SBAWE_SEQ is not set +# CONFIG_SND_EMU10K1_SEQ is not set +CONFIG_SND_OPL3_LIB=m +CONFIG_SND_AC97_CODEC=m +CONFIG_SND_DRIVERS=y +# CONFIG_SND_PCSP is not set +# CONFIG_SND_DUMMY is not set +# CONFIG_SND_ALOOP is not set +CONFIG_SND_VIRMIDI=m +# CONFIG_SND_MTPAV is not set +# CONFIG_SND_MTS64 is not set +# CONFIG_SND_SERIAL_U16550 is not set +# CONFIG_SND_MPU401 is not set +# CONFIG_SND_PORTMAN2X4 is not set +CONFIG_SND_AC97_POWER_SAVE=y +CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0 +CONFIG_SND_PCI=y +# CONFIG_SND_AD1889 is not set +CONFIG_SND_ALS300=m +# CONFIG_SND_ALS4000 is not set +# CONFIG_SND_ALI5451 is not set +# CONFIG_SND_ASIHPI is not set +# CONFIG_SND_ATIIXP is not set +# CONFIG_SND_ATIIXP_MODEM is not set +# CONFIG_SND_AU8810 is not set +# CONFIG_SND_AU8820 is not set +# CONFIG_SND_AU8830 is not set +# CONFIG_SND_AW2 is not set +# CONFIG_SND_AZT3328 is not set +# CONFIG_SND_BT87X is not set +# CONFIG_SND_CA0106 is not set +# CONFIG_SND_CMIPCI is not set +# CONFIG_SND_OXYGEN is not set +# CONFIG_SND_CS4281 is not set +# CONFIG_SND_CS46XX is not set +# CONFIG_SND_CTXFI is not set +# CONFIG_SND_DARLA20 is not set +# CONFIG_SND_GINA20 is not set +# CONFIG_SND_LAYLA20 is not set +# CONFIG_SND_DARLA24 is not set +# CONFIG_SND_GINA24 is not set +# CONFIG_SND_LAYLA24 is not set +# CONFIG_SND_MONA is not set +# CONFIG_SND_MIA is not set +# CONFIG_SND_ECHO3G is not set +# CONFIG_SND_INDIGO is not set +# CONFIG_SND_INDIGOIO is not set +# CONFIG_SND_INDIGODJ is not set +# CONFIG_SND_INDIGOIOX is not set +# CONFIG_SND_INDIGODJX is not set +# CONFIG_SND_EMU10K1 is not set +# CONFIG_SND_EMU10K1X is not set +# CONFIG_SND_ENS1370 is not set +CONFIG_SND_ENS1371=m +# CONFIG_SND_ES1938 is not set +# CONFIG_SND_ES1968 is not set +# CONFIG_SND_FM801 is not set +# CONFIG_SND_HDSP is not set +# CONFIG_SND_HDSPM is not set +# CONFIG_SND_ICE1712 is not set +# CONFIG_SND_ICE1724 is not set +# CONFIG_SND_INTEL8X0 is not set +# CONFIG_SND_INTEL8X0M is not set +# CONFIG_SND_KORG1212 is not set +# CONFIG_SND_LOLA is not set +# CONFIG_SND_LX6464ES is not set +# CONFIG_SND_MAESTRO3 is not set +# CONFIG_SND_MIXART is not set +# CONFIG_SND_NM256 is not set +# CONFIG_SND_PCXHR is not set +# CONFIG_SND_RIPTIDE is not set +# CONFIG_SND_RME32 is not set +# CONFIG_SND_RME96 is not set +# CONFIG_SND_RME9652 is not set +# CONFIG_SND_SE6X is not set +# CONFIG_SND_SONICVIBES is not set +# CONFIG_SND_TRIDENT is not set +# CONFIG_SND_VIA82XX is not set +# CONFIG_SND_VIA82XX_MODEM is not set +# CONFIG_SND_VIRTUOSO is not set +# CONFIG_SND_VX222 is not set +# CONFIG_SND_YMFPCI is not set + +# +# HD-Audio +# +# CONFIG_SND_HDA_INTEL is not set +CONFIG_SND_HDA_PREALLOC_SIZE=64 +CONFIG_SND_SPI=y +CONFIG_SND_USB=y +# CONFIG_SND_USB_AUDIO is not set +# CONFIG_SND_USB_UA101 is not set +# CONFIG_SND_USB_USX2Y is not set +# CONFIG_SND_USB_CAIAQ is not set +# CONFIG_SND_USB_US122L is not set +# CONFIG_SND_USB_6FIRE is not set +# CONFIG_SND_USB_HIFACE is not set +# CONFIG_SND_BCD2000 is not set +# CONFIG_SND_USB_POD is not set +# CONFIG_SND_USB_PODHD is not set +# CONFIG_SND_USB_TONEPORT is not set +# CONFIG_SND_USB_VARIAX is not set +# CONFIG_SND_SOC is not set +CONFIG_SND_X86=y +# CONFIG_SOUND_PRIME is not set +CONFIG_AC97_BUS=m + +# +# HID support +# +CONFIG_HID=m +CONFIG_HID_BATTERY_STRENGTH=y +CONFIG_HIDRAW=y +# CONFIG_UHID is not set +CONFIG_HID_GENERIC=m + +# +# Special HID drivers +# +# CONFIG_HID_A4TECH is not set +# CONFIG_HID_ACRUX is not set +# CONFIG_HID_APPLE is not set +# CONFIG_HID_APPLEIR is not set +# CONFIG_HID_AUREAL is not set +# CONFIG_HID_BELKIN is not set +# CONFIG_HID_BETOP_FF is not set +# CONFIG_HID_CHERRY is not set +# CONFIG_HID_CHICONY is not set +# CONFIG_HID_CORSAIR is not set +# CONFIG_HID_PRODIKEYS is not set +# CONFIG_HID_CMEDIA is not set +# CONFIG_HID_CP2112 is not set +# CONFIG_HID_CYPRESS is not set +# CONFIG_HID_DRAGONRISE is not set +# CONFIG_HID_EMS_FF is not set +# CONFIG_HID_ELECOM is not set +# CONFIG_HID_ELO is not set +# CONFIG_HID_EZKEY is not set +# CONFIG_HID_GEMBIRD is not set +# CONFIG_HID_GFRM is not set +# CONFIG_HID_HOLTEK is not set +# CONFIG_HID_GT683R is not set +# CONFIG_HID_KEYTOUCH is not set +# CONFIG_HID_KYE is not set +# CONFIG_HID_UCLOGIC is not set +# CONFIG_HID_WALTOP is not set +# CONFIG_HID_GYRATION is not set +# CONFIG_HID_ICADE is not set +# CONFIG_HID_TWINHAN is not set +# CONFIG_HID_KENSINGTON is not set +# CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LED is not set +# CONFIG_HID_LENOVO is not set +# CONFIG_HID_LOGITECH is not set +# CONFIG_HID_MAGICMOUSE is not set +# CONFIG_HID_MAYFLASH is not set +# CONFIG_HID_MICROSOFT is not set +# CONFIG_HID_MONTEREY is not set +# CONFIG_HID_MULTITOUCH is not set +# CONFIG_HID_NTRIG is not set +# CONFIG_HID_ORTEK is not set +# CONFIG_HID_PANTHERLORD is not set +# CONFIG_HID_PENMOUNT is not set +# CONFIG_HID_PETALYNX is not set +# CONFIG_HID_PICOLCD is not set +# CONFIG_HID_PLANTRONICS is not set +# CONFIG_HID_PRIMAX is not set +# CONFIG_HID_ROCCAT is not set +# CONFIG_HID_SAITEK is not set +# CONFIG_HID_SAMSUNG is not set +# CONFIG_HID_SONY is not set +# CONFIG_HID_SPEEDLINK is not set +# CONFIG_HID_STEELSERIES is not set +# CONFIG_HID_SUNPLUS is not set +# CONFIG_HID_RMI is not set +# CONFIG_HID_GREENASIA is not set +# CONFIG_HID_SMARTJOYPLUS is not set +# CONFIG_HID_TIVO is not set +# CONFIG_HID_TOPSEED is not set +# CONFIG_HID_THINGM is not set +# CONFIG_HID_THRUSTMASTER is not set +# CONFIG_HID_UDRAW_PS3 is not set +# CONFIG_HID_WACOM is not set +# CONFIG_HID_WIIMOTE is not set +# CONFIG_HID_XINMO is not set +# CONFIG_HID_ZEROPLUS is not set +# CONFIG_HID_ZYDACRON is not set +# CONFIG_HID_SENSOR_HUB is not set +# CONFIG_HID_ALPS is not set + +# +# USB HID support +# +CONFIG_USB_HID=m +CONFIG_HID_PID=y +CONFIG_USB_HIDDEV=y + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set + +# +# I2C HID support +# +# CONFIG_I2C_HID is not set + +# +# Intel ISH HID support +# +# CONFIG_INTEL_ISH_HID is not set +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_COMMON=y +CONFIG_USB_ARCH_HAS_HCD=y +CONFIG_USB=y +CONFIG_USB_ANNOUNCE_NEW_DEVICES=y + +# +# Miscellaneous USB options +# +CONFIG_USB_DEFAULT_PERSIST=y +CONFIG_USB_DYNAMIC_MINORS=y +# CONFIG_USB_OTG is not set +# CONFIG_USB_OTG_WHITELIST is not set +# CONFIG_USB_OTG_BLACKLIST_HUB is not set +# CONFIG_USB_LEDS_TRIGGER_USBPORT is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +# CONFIG_USB_XHCI_PLATFORM is not set +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_ROOT_HUB_TT=y +CONFIG_USB_EHCI_TT_NEWSCHED=y +CONFIG_USB_EHCI_PCI=y +CONFIG_USB_EHCI_HCD_PLATFORM=y +# CONFIG_USB_OXU210HP_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_ISP1362_HCD is not set +# CONFIG_USB_FOTG210_HCD is not set +# CONFIG_USB_MAX3421_HCD is not set +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_HCD_PCI=y +CONFIG_USB_OHCI_HCD_PLATFORM=y +CONFIG_USB_UHCI_HCD=y +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HCD_TEST_MODE is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may +# + +# +# also be needed; see USB_STORAGE Help for more info +# +# CONFIG_USB_STORAGE is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set +# CONFIG_USBIP_CORE is not set +# CONFIG_USB_MUSB_HDRC is not set +# CONFIG_USB_DWC3 is not set +CONFIG_USB_DWC2=y +CONFIG_USB_DWC2_HOST=y + +# +# Gadget/Dual-role mode requires USB Gadget support to be enabled +# +# CONFIG_USB_DWC2_PCI is not set +# CONFIG_USB_DWC2_DEBUG is not set +# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set +# CONFIG_USB_CHIPIDEA is not set +# CONFIG_USB_ISP1760 is not set + +# +# USB port drivers +# +# CONFIG_USB_USS720 is not set +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_SISUSBVGA is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_EHSET_TEST_FIXTURE is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_YUREX is not set +# CONFIG_USB_EZUSB_FX2 is not set +# CONFIG_USB_HUB_USB251XB is not set +# CONFIG_USB_HSIC_USB3503 is not set +# CONFIG_USB_HSIC_USB4604 is not set +# CONFIG_USB_LINK_LAYER_TEST is not set +# CONFIG_USB_CHAOSKEY is not set +# CONFIG_UCSI is not set + +# +# USB Physical Layer drivers +# +# CONFIG_USB_PHY is not set +# CONFIG_NOP_USB_XCEIV is not set +# CONFIG_USB_GPIO_VBUS is not set +# CONFIG_USB_ISP1301 is not set +# CONFIG_USB_GADGET is not set +CONFIG_USB_LED_TRIG=y +# CONFIG_USB_ULPI_BUS is not set +# CONFIG_UWB is not set +CONFIG_MMC=y +# CONFIG_MMC_DEBUG is not set +# CONFIG_MMC_BLOCK is not set +# CONFIG_SDIO_UART is not set +# CONFIG_MMC_TEST is not set + +# +# MMC/SD/SDIO Host Controller Drivers +# +# CONFIG_MMC_SDHCI is not set +# CONFIG_MMC_WBSD is not set +# CONFIG_MMC_TIFM_SD is not set +# CONFIG_MMC_SPI is not set +# CONFIG_MMC_CB710 is not set +# CONFIG_MMC_VIA_SDMMC is not set +# CONFIG_MMC_VUB300 is not set +# CONFIG_MMC_USHC is not set +# CONFIG_MMC_USDHI6ROL0 is not set +# CONFIG_MMC_TOSHIBA_PCI is not set +# CONFIG_MMC_MTK is not set +# CONFIG_MEMSTICK is not set +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y +# CONFIG_LEDS_CLASS_FLASH is not set +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set + +# +# LED drivers +# +# CONFIG_LEDS_88PM860X is not set +# CONFIG_LEDS_LM3530 is not set +# CONFIG_LEDS_LM3642 is not set +# CONFIG_LEDS_PCA9532 is not set +# CONFIG_LEDS_GPIO is not set +# CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_LP3952 is not set +# CONFIG_LEDS_LP5521 is not set +# CONFIG_LEDS_LP5523 is not set +# CONFIG_LEDS_LP5562 is not set +# CONFIG_LEDS_LP8501 is not set +# CONFIG_LEDS_LP8788 is not set +# CONFIG_LEDS_LP8860 is not set +# CONFIG_LEDS_CLEVO_MAIL is not set +# CONFIG_LEDS_PCA955X is not set +# CONFIG_LEDS_PCA963X is not set +# CONFIG_LEDS_WM831X_STATUS is not set +# CONFIG_LEDS_WM8350 is not set +# CONFIG_LEDS_DA903X is not set +# CONFIG_LEDS_DA9052 is not set +# CONFIG_LEDS_DAC124S085 is not set +# CONFIG_LEDS_PWM is not set +# CONFIG_LEDS_REGULATOR is not set +# CONFIG_LEDS_BD2802 is not set +# CONFIG_LEDS_INTEL_SS4200 is not set +# CONFIG_LEDS_LT3593 is not set +# CONFIG_LEDS_ADP5520 is not set +# CONFIG_LEDS_TCA6507 is not set +# CONFIG_LEDS_TLC591XX is not set +# CONFIG_LEDS_MAX8997 is not set +# CONFIG_LEDS_LM355x is not set + +# +# LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM) +# +# CONFIG_LEDS_BLINKM is not set +# CONFIG_LEDS_MLXCPLD is not set +# CONFIG_LEDS_USER is not set +# CONFIG_LEDS_NIC78BX is not set + +# +# LED Triggers +# +CONFIG_LEDS_TRIGGERS=y +# CONFIG_LEDS_TRIGGER_TIMER is not set +# CONFIG_LEDS_TRIGGER_ONESHOT is not set +CONFIG_LEDS_TRIGGER_DISK=y +# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +CONFIG_LEDS_TRIGGER_CPU=y +# CONFIG_LEDS_TRIGGER_GPIO is not set +# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set + +# +# iptables trigger is under Netfilter config (LED target) +# +# CONFIG_LEDS_TRIGGER_TRANSIENT is not set +# CONFIG_LEDS_TRIGGER_CAMERA is not set +CONFIG_LEDS_TRIGGER_PANIC=y +# CONFIG_ACCESSIBILITY is not set +# CONFIG_INFINIBAND is not set +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_EDAC=y +# CONFIG_EDAC_LEGACY_SYSFS is not set +# CONFIG_EDAC_DEBUG is not set +# CONFIG_EDAC_DECODE_MCE is not set +# CONFIG_EDAC_MM_EDAC is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_MC146818_LIB=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_HCTOSYS=y +CONFIG_RTC_HCTOSYS_DEVICE="rtc0" +CONFIG_RTC_SYSTOHC=y +CONFIG_RTC_SYSTOHC_DEVICE="rtc0" +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_88PM860X is not set +# CONFIG_RTC_DRV_ABB5ZES3 is not set +# CONFIG_RTC_DRV_ABX80X is not set +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_LP8788 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_MAX8925 is not set +# CONFIG_RTC_DRV_MAX8998 is not set +# CONFIG_RTC_DRV_MAX8997 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_ISL12022 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8523 is not set +# CONFIG_RTC_DRV_PCF85063 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_BQ32K is not set +# CONFIG_RTC_DRV_PALMAS is not set +# CONFIG_RTC_DRV_TPS6586X is not set +# CONFIG_RTC_DRV_TPS65910 is not set +# CONFIG_RTC_DRV_TPS80031 is not set +# CONFIG_RTC_DRV_RC5T583 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8010 is not set +# CONFIG_RTC_DRV_RX8581 is not set +# CONFIG_RTC_DRV_RX8025 is not set +# CONFIG_RTC_DRV_EM3027 is not set +# CONFIG_RTC_DRV_RV8803 is not set +# CONFIG_RTC_DRV_S5M is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T93 is not set +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1302 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1343 is not set +# CONFIG_RTC_DRV_DS1347 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6916 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RX4581 is not set +# CONFIG_RTC_DRV_RX6110 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_PCF2123 is not set +# CONFIG_RTC_DRV_MCP795 is not set +CONFIG_RTC_I2C_AND_SPI=y + +# +# SPI and I2C RTC drivers +# +# CONFIG_RTC_DRV_DS3232 is not set +# CONFIG_RTC_DRV_PCF2127 is not set +# CONFIG_RTC_DRV_RV3029C2 is not set + +# +# Platform RTC drivers +# +CONFIG_RTC_DRV_CMOS=y +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1685_FAMILY is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_DS2404 is not set +# CONFIG_RTC_DRV_DA9052 is not set +# CONFIG_RTC_DRV_DA9055 is not set +# CONFIG_RTC_DRV_DA9063 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_MSM6242 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_RP5C01 is not set +# CONFIG_RTC_DRV_V3020 is not set +# CONFIG_RTC_DRV_WM831X is not set +# CONFIG_RTC_DRV_WM8350 is not set +# CONFIG_RTC_DRV_AB3100 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PCAP is not set + +# +# HID Sensor RTC drivers +# +# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set +CONFIG_DMADEVICES=y +# CONFIG_DMADEVICES_DEBUG is not set + +# +# DMA Devices +# +CONFIG_DMA_ENGINE=y +CONFIG_DMA_ACPI=y +# CONFIG_INTEL_IDMA64 is not set +# CONFIG_INTEL_IOATDMA is not set +# CONFIG_QCOM_HIDMA_MGMT is not set +# CONFIG_QCOM_HIDMA is not set +CONFIG_DW_DMAC_CORE=y +# CONFIG_DW_DMAC is not set +CONFIG_DW_DMAC_PCI=y + +# +# DMA Clients +# +CONFIG_ASYNC_TX_DMA=y +# CONFIG_DMATEST is not set + +# +# DMABUF options +# +CONFIG_SYNC_FILE=y +# CONFIG_SW_SYNC is not set +CONFIG_AUXDISPLAY=y +# CONFIG_KS0108 is not set +# CONFIG_IMG_ASCII_LCD is not set +# CONFIG_UIO is not set +# CONFIG_VFIO is not set +CONFIG_VIRT_DRIVERS=y +CONFIG_VIRTIO=y + +# +# Virtio drivers +# +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_PCI_LEGACY=y +CONFIG_VIRTIO_BALLOON=y +# CONFIG_VIRTIO_INPUT is not set +CONFIG_VIRTIO_MMIO=y +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y + +# +# Microsoft Hyper-V guest support +# +# CONFIG_HYPERV is not set + +# +# Xen driver support +# +CONFIG_XEN_BALLOON=y +CONFIG_XEN_SELFBALLOONING=y +CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y +CONFIG_XEN_BALLOON_MEMORY_HOTPLUG_LIMIT=512 +CONFIG_XEN_SCRUB_PAGES=y +# CONFIG_XEN_DEV_EVTCHN is not set +CONFIG_XEN_BACKEND=y +# CONFIG_XENFS is not set +CONFIG_XEN_SYS_HYPERVISOR=y +CONFIG_XEN_XENBUS_FRONTEND=y +# CONFIG_XEN_GNTDEV is not set +# CONFIG_XEN_GRANT_DEV_ALLOC is not set +CONFIG_SWIOTLB_XEN=y +CONFIG_XEN_TMEM=m +# CONFIG_XEN_PCIDEV_BACKEND is not set +CONFIG_XEN_PRIVCMD=m +CONFIG_XEN_ACPI_PROCESSOR=y +CONFIG_XEN_MCE_LOG=y +CONFIG_XEN_HAVE_PVMMU=y +CONFIG_XEN_EFI=y +CONFIG_XEN_AUTO_XLATE=y +CONFIG_XEN_ACPI=y +CONFIG_XEN_HAVE_VPMU=y +CONFIG_STAGING=y +# CONFIG_COMEDI is not set +# CONFIG_RTL8192U is not set +# CONFIG_RTLLIB is not set +# CONFIG_R8712U is not set +# CONFIG_RTS5208 is not set +# CONFIG_FB_SM750 is not set +# CONFIG_FB_XGI is not set + +# +# Speakup console speech +# +# CONFIG_SPEAKUP is not set +CONFIG_STAGING_MEDIA=y +# CONFIG_I2C_BCM2048 is not set +# CONFIG_DVB_CXD2099 is not set + +# +# Android +# +# CONFIG_LTE_GDM724X is not set +# CONFIG_LNET is not set +# CONFIG_DGNC is not set +# CONFIG_GS_FPGABOOT is not set +CONFIG_CRYPTO_SKEIN=y +CONFIG_UNISYSSPAR=y +# CONFIG_UNISYS_VISORBUS is not set +# CONFIG_FB_TFT is not set +# CONFIG_MOST is not set +# CONFIG_KS7010 is not set +# CONFIG_GREYBUS is not set +CONFIG_X86_PLATFORM_DEVICES=y +# CONFIG_ACERHDF is not set +# CONFIG_ASUS_LAPTOP is not set +# CONFIG_DELL_LAPTOP is not set +# CONFIG_DELL_SMO8800 is not set +# CONFIG_DELL_RBTN is not set +# CONFIG_FUJITSU_LAPTOP is not set +# CONFIG_FUJITSU_TABLET is not set +# CONFIG_AMILO_RFKILL is not set +# CONFIG_HP_ACCEL is not set +# CONFIG_HP_WIRELESS is not set +# CONFIG_MSI_LAPTOP is not set +# CONFIG_PANASONIC_LAPTOP is not set +# CONFIG_COMPAL_LAPTOP is not set +# CONFIG_SONY_LAPTOP is not set +# CONFIG_IDEAPAD_LAPTOP is not set +# CONFIG_THINKPAD_ACPI is not set +# CONFIG_SENSORS_HDAPS is not set +# CONFIG_INTEL_MENLOW is not set +# CONFIG_EEEPC_LAPTOP is not set +# CONFIG_ASUS_WIRELESS is not set +# CONFIG_ACPI_WMI is not set +# CONFIG_TOPSTAR_LAPTOP is not set +# CONFIG_TOSHIBA_BT_RFKILL is not set +# CONFIG_TOSHIBA_HAPS is not set +# CONFIG_ACPI_CMPC is not set +# CONFIG_INTEL_HID_EVENT is not set +# CONFIG_INTEL_VBTN is not set +# CONFIG_INTEL_IPS is not set +CONFIG_INTEL_PMC_CORE=y +# CONFIG_IBM_RTL is not set +# CONFIG_SAMSUNG_LAPTOP is not set +# CONFIG_INTEL_OAKTRAIL is not set +# CONFIG_SAMSUNG_Q10 is not set +# CONFIG_APPLE_GMUX is not set +# CONFIG_INTEL_RST is not set +# CONFIG_INTEL_SMARTCONNECT is not set +# CONFIG_PVPANIC is not set +# CONFIG_INTEL_PMC_IPC is not set +# CONFIG_SURFACE_PRO3_BUTTON is not set +# CONFIG_INTEL_PUNIT_IPC is not set +# CONFIG_MLX_PLATFORM is not set +# CONFIG_MLX_CPLD_PLATFORM is not set +# CONFIG_INTEL_TURBO_MAX_3 is not set +# CONFIG_SILEAD_DMI is not set +CONFIG_PMC_ATOM=y +CONFIG_CHROME_PLATFORMS=y +# CONFIG_CHROMEOS_LAPTOP is not set +# CONFIG_CHROMEOS_PSTORE is not set +# CONFIG_CROS_KBD_LED_BACKLIGHT is not set +CONFIG_CLKDEV_LOOKUP=y +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_COMMON_CLK=y + +# +# Common Clock Framework +# +# CONFIG_COMMON_CLK_WM831X is not set +# CONFIG_COMMON_CLK_SI5351 is not set +# CONFIG_COMMON_CLK_CDCE706 is not set +# CONFIG_COMMON_CLK_CS2000_CP is not set +# CONFIG_COMMON_CLK_S2MPS11 is not set +# CONFIG_CLK_TWL6040 is not set +# CONFIG_COMMON_CLK_NXP is not set +# CONFIG_COMMON_CLK_PALMAS is not set +# CONFIG_COMMON_CLK_PWM is not set +# CONFIG_COMMON_CLK_PXA is not set +# CONFIG_COMMON_CLK_PIC32 is not set + +# +# Hardware Spinlock drivers +# + +# +# Clock Source drivers +# +CONFIG_CLKEVT_I8253=y +CONFIG_I8253_LOCK=y +CONFIG_CLKBLD_I8253=y +# CONFIG_ATMEL_PIT is not set +# CONFIG_SH_TIMER_CMT is not set +# CONFIG_SH_TIMER_MTU2 is not set +# CONFIG_SH_TIMER_TMU is not set +# CONFIG_EM_TIMER_STI is not set +CONFIG_MAILBOX=y +CONFIG_PCC=y +# CONFIG_ALTERA_MBOX is not set +CONFIG_IOMMU_API=y +CONFIG_IOMMU_SUPPORT=y + +# +# Generic IOMMU Pagetable Support +# +CONFIG_IOMMU_IOVA=y +CONFIG_AMD_IOMMU=y +# CONFIG_AMD_IOMMU_V2 is not set +CONFIG_DMAR_TABLE=y +CONFIG_INTEL_IOMMU=y +CONFIG_INTEL_IOMMU_SVM=y +# CONFIG_INTEL_IOMMU_DEFAULT_ON is not set +CONFIG_INTEL_IOMMU_FLOPPY_WA=y +CONFIG_IRQ_REMAP=y + +# +# Remoteproc drivers +# +# CONFIG_REMOTEPROC is not set + +# +# Rpmsg drivers +# + +# +# SOC (System On Chip) specific Drivers +# + +# +# Broadcom SoC drivers +# +# CONFIG_SUNXI_SRAM is not set +CONFIG_SOC_TI=y +# CONFIG_SOC_ZTE is not set +CONFIG_PM_DEVFREQ=y + +# +# DEVFREQ Governors +# +CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y +CONFIG_DEVFREQ_GOV_PERFORMANCE=y +CONFIG_DEVFREQ_GOV_POWERSAVE=y +CONFIG_DEVFREQ_GOV_USERSPACE=y +CONFIG_DEVFREQ_GOV_PASSIVE=y + +# +# DEVFREQ Drivers +# +CONFIG_PM_DEVFREQ_EVENT=y +CONFIG_EXTCON=y + +# +# Extcon Device Drivers +# +# CONFIG_EXTCON_GPIO is not set +# CONFIG_EXTCON_INTEL_INT3496 is not set +# CONFIG_EXTCON_MAX14577 is not set +# CONFIG_EXTCON_MAX3355 is not set +# CONFIG_EXTCON_MAX77693 is not set +# CONFIG_EXTCON_MAX77843 is not set +# CONFIG_EXTCON_MAX8997 is not set +# CONFIG_EXTCON_PALMAS is not set +# CONFIG_EXTCON_QCOM_SPMI_MISC is not set +# CONFIG_EXTCON_RT8973A is not set +# CONFIG_EXTCON_SM5502 is not set +# CONFIG_EXTCON_USB_GPIO is not set +CONFIG_MEMORY=y +# CONFIG_IIO is not set +# CONFIG_NTB is not set +CONFIG_VME_BUS=y + +# +# VME Bridge Drivers +# +# CONFIG_VME_CA91CX42 is not set +# CONFIG_VME_TSI148 is not set +# CONFIG_VME_FAKE is not set + +# +# VME Board Drivers +# +# CONFIG_VMIVME_7805 is not set + +# +# VME Device Drivers +# +# CONFIG_VME_USER is not set +# CONFIG_VME_PIO2 is not set +CONFIG_PWM=y +CONFIG_PWM_SYSFS=y +CONFIG_PWM_CRC=y +# CONFIG_PWM_LPSS_PCI is not set +# CONFIG_PWM_LPSS_PLATFORM is not set +# CONFIG_PWM_PCA9685 is not set +# CONFIG_PWM_TWL is not set +# CONFIG_PWM_TWL_LED is not set +CONFIG_ARM_GIC_MAX_NR=1 +# CONFIG_IPACK_BUS is not set +CONFIG_RESET_CONTROLLER=y +# CONFIG_RESET_ATH79 is not set +# CONFIG_RESET_BERLIN is not set +# CONFIG_RESET_LPC18XX is not set +# CONFIG_RESET_MESON is not set +# CONFIG_RESET_PISTACHIO is not set +# CONFIG_RESET_SOCFPGA is not set +# CONFIG_RESET_STM32 is not set +# CONFIG_RESET_SUNXI is not set +# CONFIG_TI_SYSCON_RESET is not set +# CONFIG_RESET_ZYNQ is not set +# CONFIG_RESET_TEGRA_BPMP is not set +# CONFIG_FMC is not set + +# +# PHY Subsystem +# +CONFIG_GENERIC_PHY=y +# CONFIG_PHY_PXA_28NM_HSIC is not set +# CONFIG_PHY_PXA_28NM_USB2 is not set +# CONFIG_BCM_KONA_USB2_PHY is not set +# CONFIG_PHY_SAMSUNG_USB2 is not set +CONFIG_POWERCAP=y +# CONFIG_INTEL_RAPL is not set +# CONFIG_MCB is not set + +# +# Performance monitor support +# +CONFIG_RAS=y +# CONFIG_MCE_AMD_INJ is not set +# CONFIG_THUNDERBOLT is not set + +# +# Android +# +# CONFIG_ANDROID is not set +CONFIG_LIBNVDIMM=y +# CONFIG_BLK_DEV_PMEM is not set +# CONFIG_ND_BLK is not set +CONFIG_ND_CLAIM=y +CONFIG_BTT=y +CONFIG_NVDIMM_PFN=y +CONFIG_NVDIMM_DAX=y +# CONFIG_DEV_DAX is not set +# CONFIG_NVMEM is not set +# CONFIG_STM is not set +# CONFIG_INTEL_TH is not set + +# +# FPGA Configuration Support +# +# CONFIG_FPGA is not set + +# +# FSI support +# +# CONFIG_FSI is not set + +# +# Firmware Drivers +# +CONFIG_EDD=y +CONFIG_EDD_OFF=y +CONFIG_FIRMWARE_MEMMAP=y +# CONFIG_DELL_RBU is not set +# CONFIG_DCDBAS is not set +CONFIG_DMIID=y +# CONFIG_DMI_SYSFS is not set +CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y +CONFIG_ISCSI_IBFT_FIND=y +# CONFIG_ISCSI_IBFT is not set +# CONFIG_FW_CFG_SYSFS is not set +# CONFIG_GOOGLE_FIRMWARE is not set + +# +# EFI (Extensible Firmware Interface) Support +# +CONFIG_EFI_VARS=y +CONFIG_EFI_ESRT=y +# CONFIG_EFI_VARS_PSTORE is not set +CONFIG_EFI_RUNTIME_MAP=y +# CONFIG_EFI_FAKE_MEMMAP is not set +CONFIG_EFI_RUNTIME_WRAPPERS=y +# CONFIG_EFI_BOOTLOADER_CONTROL is not set +# CONFIG_EFI_CAPSULE_LOADER is not set +# CONFIG_EFI_TEST is not set +# CONFIG_APPLE_PROPERTIES is not set +CONFIG_UEFI_CPER=y +# CONFIG_EFI_DEV_PATH_PARSER is not set + +# +# Tegra firmware driver +# + +# +# File systems +# +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_FS_IOMAP=y +# CONFIG_EXT2_FS is not set +# CONFIG_EXT3_FS is not set +CONFIG_EXT4_FS=y +CONFIG_EXT4_USE_FOR_EXT2=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_EXT4_ENCRYPTION=y +CONFIG_EXT4_FS_ENCRYPTION=y +# CONFIG_EXT4_DEBUG is not set +CONFIG_JBD2=y +# CONFIG_JBD2_DEBUG is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_XFS_FS is not set +# CONFIG_GFS2_FS is not set +# CONFIG_BTRFS_FS is not set +# CONFIG_NILFS2_FS is not set +# CONFIG_F2FS_FS is not set +CONFIG_FS_DAX=y +CONFIG_FS_DAX_PMD=y +CONFIG_FS_POSIX_ACL=y +CONFIG_EXPORTFS=y +CONFIG_EXPORTFS_BLOCK_OPS=y +CONFIG_FILE_LOCKING=y +CONFIG_MANDATORY_FILE_LOCKING=y +CONFIG_FS_ENCRYPTION=y +CONFIG_FSNOTIFY=y +CONFIG_DNOTIFY=y +CONFIG_INOTIFY_USER=y +CONFIG_FANOTIFY=y +CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y +CONFIG_QUOTA=y +CONFIG_QUOTA_NETLINK_INTERFACE=y +# CONFIG_PRINT_QUOTA_WARNING is not set +# CONFIG_QUOTA_DEBUG is not set +# CONFIG_QFMT_V1 is not set +# CONFIG_QFMT_V2 is not set +CONFIG_QUOTACTL=y +CONFIG_QUOTACTL_COMPAT=y +CONFIG_AUTOFS4_FS=m +CONFIG_FUSE_FS=y +# CONFIG_CUSE is not set +# CONFIG_OVERLAY_FS is not set + +# +# Caches +# +# CONFIG_FSCACHE is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +# CONFIG_MSDOS_FS is not set +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +# CONFIG_FAT_DEFAULT_UTF8 is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y +CONFIG_PROC_VMCORE=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PROC_CHILDREN=y +CONFIG_KERNFS=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS_XATTR=y +CONFIG_HUGETLBFS=y +CONFIG_HUGETLB_PAGE=y +CONFIG_ARCH_HAS_GIGANTIC_PAGE=y +# CONFIG_CONFIGFS_FS is not set +CONFIG_EFIVAR_FS=y +CONFIG_MISC_FILESYSTEMS=y +# CONFIG_ORANGEFS_FS is not set +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +CONFIG_ECRYPT_FS=y +CONFIG_ECRYPT_FS_MESSAGING=y +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +# CONFIG_CRAMFS is not set +CONFIG_SQUASHFS=y +# CONFIG_SQUASHFS_FILE_CACHE is not set +CONFIG_SQUASHFS_FILE_DIRECT=y +CONFIG_SQUASHFS_DECOMP_SINGLE=y +# CONFIG_SQUASHFS_DECOMP_MULTI is not set +# CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU is not set +CONFIG_SQUASHFS_XATTR=y +CONFIG_SQUASHFS_ZLIB=y +CONFIG_SQUASHFS_LZ4=y +CONFIG_SQUASHFS_LZO=y +CONFIG_SQUASHFS_XZ=y +# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set +# CONFIG_SQUASHFS_EMBEDDED is not set +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_QNX6FS_FS is not set +# CONFIG_ROMFS_FS is not set +CONFIG_PSTORE=y +CONFIG_PSTORE_ZLIB_COMPRESS=y +# CONFIG_PSTORE_LZO_COMPRESS is not set +# CONFIG_PSTORE_LZ4_COMPRESS is not set +# CONFIG_PSTORE_CONSOLE is not set +# CONFIG_PSTORE_PMSG is not set +# CONFIG_PSTORE_FTRACE is not set +# CONFIG_PSTORE_RAM is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +# CONFIG_NFS_FS is not set +# CONFIG_NFSD is not set +# CONFIG_CEPH_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +# CONFIG_NLS_ASCII is not set +# CONFIG_NLS_ISO8859_1 is not set +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +# CONFIG_NLS_MAC_ROMAN is not set +# CONFIG_NLS_MAC_CELTIC is not set +# CONFIG_NLS_MAC_CENTEURO is not set +# CONFIG_NLS_MAC_CROATIAN is not set +# CONFIG_NLS_MAC_CYRILLIC is not set +# CONFIG_NLS_MAC_GAELIC is not set +# CONFIG_NLS_MAC_GREEK is not set +# CONFIG_NLS_MAC_ICELAND is not set +# CONFIG_NLS_MAC_INUIT is not set +# CONFIG_NLS_MAC_ROMANIAN is not set +# CONFIG_NLS_MAC_TURKISH is not set +# CONFIG_NLS_UTF8 is not set + +# +# Kernel hacking +# +CONFIG_TRACE_IRQFLAGS_SUPPORT=y + +# +# printk and dmesg options +# +CONFIG_PRINTK_TIME=y +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 +CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 +CONFIG_BOOT_PRINTK_DELAY=y +CONFIG_DYNAMIC_DEBUG=y + +# +# Compile-time checks and compiler options +# +CONFIG_DEBUG_INFO=y +# CONFIG_DEBUG_INFO_REDUCED is not set +# CONFIG_DEBUG_INFO_SPLIT is not set +CONFIG_DEBUG_INFO_DWARF4=y +CONFIG_GDB_SCRIPTS=y +# CONFIG_ENABLE_WARN_DEPRECATED is not set +# CONFIG_ENABLE_MUST_CHECK is not set +CONFIG_FRAME_WARN=1024 +# CONFIG_STRIP_ASM_SYMS is not set +# CONFIG_READABLE_ASM is not set +CONFIG_UNUSED_SYMBOLS=y +# CONFIG_PAGE_OWNER is not set +CONFIG_DEBUG_FS=y +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_SECTION_MISMATCH is not set +CONFIG_SECTION_MISMATCH_WARN_ONLY=y +CONFIG_ARCH_WANT_FRAME_POINTERS=y +CONFIG_FRAME_POINTER=y +# CONFIG_STACK_VALIDATION is not set +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set +CONFIG_MAGIC_SYSRQ=y +CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x01b6 +CONFIG_MAGIC_SYSRQ_SERIAL=y +CONFIG_DEBUG_KERNEL=y + +# +# Memory Debugging +# +# CONFIG_PAGE_EXTENSION is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_PAGE_POISONING is not set +# CONFIG_DEBUG_PAGE_REF is not set +# CONFIG_DEBUG_RODATA_TEST is not set +# CONFIG_DEBUG_OBJECTS is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_HAVE_DEBUG_KMEMLEAK=y +# CONFIG_DEBUG_KMEMLEAK is not set +# CONFIG_DEBUG_STACK_USAGE is not set +# CONFIG_DEBUG_VM is not set +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +# CONFIG_DEBUG_VIRTUAL is not set +# CONFIG_DEBUG_MEMORY_INIT is not set +# CONFIG_DEBUG_PER_CPU_MAPS is not set +CONFIG_HAVE_DEBUG_STACKOVERFLOW=y +# CONFIG_DEBUG_STACKOVERFLOW is not set +CONFIG_HAVE_ARCH_KMEMCHECK=y +CONFIG_HAVE_ARCH_KASAN=y +# CONFIG_KASAN is not set +CONFIG_ARCH_HAS_KCOV=y +# CONFIG_KCOV is not set +# CONFIG_DEBUG_SHIRQ is not set + +# +# Debug Lockups and Hangs +# +CONFIG_LOCKUP_DETECTOR=y +CONFIG_HARDLOCKUP_DETECTOR=y +# CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is not set +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE=0 +# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set +CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set +CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0 +# CONFIG_WQ_WATCHDOG is not set +# CONFIG_PANIC_ON_OOPS is not set +CONFIG_PANIC_ON_OOPS_VALUE=0 +CONFIG_PANIC_TIMEOUT=0 +CONFIG_SCHED_DEBUG=y +CONFIG_SCHED_INFO=y +CONFIG_SCHEDSTATS=y +CONFIG_SCHED_STACK_END_CHECK=y +# CONFIG_DEBUG_TIMEKEEPING is not set + +# +# Lock Debugging (spinlocks, mutexes, etc...) +# +# CONFIG_DEBUG_RT_MUTEXES is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_MUTEXES is not set +# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set +# CONFIG_DEBUG_LOCK_ALLOC is not set +# CONFIG_PROVE_LOCKING is not set +# CONFIG_LOCK_STAT is not set +# CONFIG_DEBUG_ATOMIC_SLEEP is not set +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set +# CONFIG_LOCK_TORTURE_TEST is not set +# CONFIG_WW_MUTEX_SELFTEST is not set +CONFIG_STACKTRACE=y +# CONFIG_DEBUG_KOBJECT is not set +CONFIG_DEBUG_BUGVERBOSE=y +# CONFIG_DEBUG_LIST is not set +# CONFIG_DEBUG_PI_LIST is not set +# CONFIG_DEBUG_SG is not set +# CONFIG_DEBUG_NOTIFIERS is not set +# CONFIG_DEBUG_CREDENTIALS is not set + +# +# RCU Debugging +# +# CONFIG_PROVE_RCU is not set +# CONFIG_SPARSE_RCU_POINTER is not set +# CONFIG_TORTURE_TEST is not set +# CONFIG_RCU_PERF_TEST is not set +# CONFIG_RCU_TORTURE_TEST is not set +CONFIG_RCU_CPU_STALL_TIMEOUT=60 +# CONFIG_RCU_TRACE is not set +# CONFIG_RCU_EQS_DEBUG is not set +# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_NOTIFIER_ERROR_INJECTION is not set +# CONFIG_FAULT_INJECTION is not set +# CONFIG_LATENCYTOP is not set +CONFIG_USER_STACKTRACE_SUPPORT=y +CONFIG_NOP_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y +CONFIG_HAVE_FENTRY=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_TRACER_MAX_TRACE=y +CONFIG_TRACE_CLOCK=y +CONFIG_RING_BUFFER=y +CONFIG_EVENT_TRACING=y +CONFIG_CONTEXT_SWITCH_TRACER=y +CONFIG_TRACING=y +CONFIG_GENERIC_TRACER=y +CONFIG_TRACING_SUPPORT=y +CONFIG_FTRACE=y +CONFIG_FUNCTION_TRACER=y +CONFIG_FUNCTION_GRAPH_TRACER=y +# CONFIG_IRQSOFF_TRACER is not set +CONFIG_SCHED_TRACER=y +# CONFIG_HWLAT_TRACER is not set +CONFIG_FTRACE_SYSCALLS=y +CONFIG_TRACER_SNAPSHOT=y +# CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP is not set +CONFIG_BRANCH_PROFILE_NONE=y +# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set +# CONFIG_PROFILE_ALL_BRANCHES is not set +CONFIG_STACK_TRACER=y +CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_KPROBE_EVENTS=y +# CONFIG_UPROBE_EVENTS is not set +CONFIG_BPF_EVENTS=y +CONFIG_PROBE_EVENTS=y +CONFIG_DYNAMIC_FTRACE=y +CONFIG_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_FUNCTION_PROFILER=y +CONFIG_FTRACE_MCOUNT_RECORD=y +# CONFIG_FTRACE_STARTUP_TEST is not set +CONFIG_MMIOTRACE=y +CONFIG_TRACING_MAP=y +CONFIG_HIST_TRIGGERS=y +# CONFIG_MMIOTRACE_TEST is not set +# CONFIG_TRACEPOINT_BENCHMARK is not set +# CONFIG_RING_BUFFER_BENCHMARK is not set +# CONFIG_RING_BUFFER_STARTUP_TEST is not set +# CONFIG_TRACE_ENUM_MAP_FILE is not set +CONFIG_TRACING_EVENTS_GPIO=y + +# +# Runtime Testing +# +# CONFIG_LKDTM is not set +# CONFIG_TEST_LIST_SORT is not set +# CONFIG_TEST_SORT is not set +# CONFIG_KPROBES_SANITY_TEST is not set +# CONFIG_BACKTRACE_SELF_TEST is not set +# CONFIG_RBTREE_TEST is not set +# CONFIG_INTERVAL_TREE_TEST is not set +# CONFIG_PERCPU_TEST is not set +# CONFIG_ATOMIC64_SELFTEST is not set +# CONFIG_TEST_HEXDUMP is not set +# CONFIG_TEST_STRING_HELPERS is not set +# CONFIG_TEST_KSTRTOX is not set +# CONFIG_TEST_PRINTF is not set +# CONFIG_TEST_BITMAP is not set +# CONFIG_TEST_UUID is not set +# CONFIG_TEST_RHASHTABLE is not set +# CONFIG_TEST_HASH is not set +# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set +# CONFIG_DMA_API_DEBUG is not set +# CONFIG_TEST_LKM is not set +# CONFIG_TEST_USER_COPY is not set +# CONFIG_TEST_BPF is not set +# CONFIG_TEST_FIRMWARE is not set +# CONFIG_TEST_UDELAY is not set +CONFIG_MEMTEST=y +# CONFIG_TEST_STATIC_KEYS is not set +# CONFIG_BUG_ON_DATA_CORRUPTION is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +CONFIG_KGDB=y +CONFIG_KGDB_SERIAL_CONSOLE=y +# CONFIG_KGDB_TESTS is not set +CONFIG_KGDB_LOW_LEVEL_TRAP=y +CONFIG_KGDB_KDB=y +CONFIG_KDB_DEFAULT_ENABLE=0x1 +CONFIG_KDB_KEYBOARD=y +CONFIG_KDB_CONTINUE_CATASTROPHIC=0 +CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y +# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set +# CONFIG_UBSAN is not set +CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y +CONFIG_STRICT_DEVMEM=y +# CONFIG_IO_STRICT_DEVMEM is not set +# CONFIG_X86_VERBOSE_BOOTUP is not set +CONFIG_EARLY_PRINTK=y +CONFIG_EARLY_PRINTK_DBGP=y +CONFIG_EARLY_PRINTK_EFI=y +CONFIG_X86_PTDUMP_CORE=y +# CONFIG_X86_PTDUMP is not set +# CONFIG_EFI_PGT_DUMP is not set +CONFIG_DEBUG_WX=y +CONFIG_DOUBLEFAULT=y +# CONFIG_DEBUG_TLBFLUSH is not set +# CONFIG_IOMMU_DEBUG is not set +# CONFIG_IOMMU_STRESS is not set +CONFIG_HAVE_MMIOTRACE_SUPPORT=y +# CONFIG_X86_DECODER_SELFTEST is not set +CONFIG_IO_DELAY_TYPE_0X80=0 +CONFIG_IO_DELAY_TYPE_0XED=1 +CONFIG_IO_DELAY_TYPE_UDELAY=2 +CONFIG_IO_DELAY_TYPE_NONE=3 +# CONFIG_IO_DELAY_0X80 is not set +CONFIG_IO_DELAY_0XED=y +# CONFIG_IO_DELAY_UDELAY is not set +# CONFIG_IO_DELAY_NONE is not set +CONFIG_DEFAULT_IO_DELAY_TYPE=1 +# CONFIG_DEBUG_BOOT_PARAMS is not set +# CONFIG_CPA_DEBUG is not set +CONFIG_OPTIMIZE_INLINING=y +# CONFIG_DEBUG_ENTRY is not set +# CONFIG_DEBUG_NMI_SELFTEST is not set +CONFIG_X86_DEBUG_FPU=y +# CONFIG_PUNIT_ATOM_DEBUG is not set + +# +# Security options +# +CONFIG_KEYS=y +CONFIG_PERSISTENT_KEYRINGS=y +CONFIG_BIG_KEYS=y +CONFIG_TRUSTED_KEYS=y +CONFIG_ENCRYPTED_KEYS=y +CONFIG_KEY_DH_OPERATIONS=y +# CONFIG_SECURITY_DMESG_RESTRICT is not set +CONFIG_SECURITY=y +CONFIG_SECURITYFS=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_PATH=y +CONFIG_INTEL_TXT=y +CONFIG_LSM_MMAP_MIN_ADDR=0 +CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y +CONFIG_HAVE_ARCH_HARDENED_USERCOPY=y +CONFIG_HARDENED_USERCOPY=y +# CONFIG_HARDENED_USERCOPY_PAGESPAN is not set +# CONFIG_STATIC_USERMODEHELPER is not set +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_SELINUX_BOOTPARAM=y +CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0 +CONFIG_SECURITY_SELINUX_DISABLE=y +CONFIG_SECURITY_SELINUX_DEVELOP=y +CONFIG_SECURITY_SELINUX_AVC_STATS=y +CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1 +CONFIG_SECURITY_SMACK=y +# CONFIG_SECURITY_SMACK_BRINGUP is not set +CONFIG_SECURITY_SMACK_NETFILTER=y +# CONFIG_SECURITY_SMACK_APPEND_SIGNALS is not set +CONFIG_SECURITY_TOMOYO=y +CONFIG_SECURITY_TOMOYO_MAX_ACCEPT_ENTRY=2048 +CONFIG_SECURITY_TOMOYO_MAX_AUDIT_LOG=1024 +# CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER is not set +CONFIG_SECURITY_TOMOYO_POLICY_LOADER="/sbin/tomoyo-init" +CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER="/sbin/init" +CONFIG_SECURITY_APPARMOR=y +CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1 +CONFIG_SECURITY_APPARMOR_HASH=y +CONFIG_SECURITY_APPARMOR_HASH_DEFAULT=y +# CONFIG_SECURITY_APPARMOR_DEBUG is not set +# CONFIG_SECURITY_LOADPIN is not set +CONFIG_SECURITY_YAMA=y +CONFIG_INTEGRITY=y +CONFIG_INTEGRITY_SIGNATURE=y +CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y +CONFIG_INTEGRITY_TRUSTED_KEYRING=y +CONFIG_INTEGRITY_AUDIT=y +CONFIG_IMA=y +CONFIG_IMA_MEASURE_PCR_IDX=10 +CONFIG_IMA_LSM_RULES=y +# CONFIG_IMA_TEMPLATE is not set +CONFIG_IMA_NG_TEMPLATE=y +# CONFIG_IMA_SIG_TEMPLATE is not set +CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng" +CONFIG_IMA_DEFAULT_HASH_SHA1=y +# CONFIG_IMA_DEFAULT_HASH_SHA256 is not set +# CONFIG_IMA_DEFAULT_HASH_SHA512 is not set +CONFIG_IMA_DEFAULT_HASH="sha1" +CONFIG_IMA_WRITE_POLICY=y +CONFIG_IMA_READ_POLICY=y +CONFIG_IMA_APPRAISE=y +CONFIG_IMA_TRUSTED_KEYRING=y +CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY=y +CONFIG_IMA_BLACKLIST_KEYRING=y +# CONFIG_IMA_LOAD_X509 is not set +CONFIG_EVM=y +CONFIG_EVM_ATTR_FSUUID=y +CONFIG_EVM_EXTRA_SMACK_XATTRS=y +# CONFIG_EVM_LOAD_X509 is not set +# CONFIG_DEFAULT_SECURITY_SELINUX is not set +# CONFIG_DEFAULT_SECURITY_SMACK is not set +# CONFIG_DEFAULT_SECURITY_TOMOYO is not set +CONFIG_DEFAULT_SECURITY_APPARMOR=y +# CONFIG_DEFAULT_SECURITY_DAC is not set +CONFIG_DEFAULT_SECURITY="apparmor" +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_ACOMP2=y +CONFIG_CRYPTO_RSA=y +# CONFIG_CRYPTO_DH is not set +# CONFIG_CRYPTO_ECDH is not set +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_USER is not set +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y +CONFIG_CRYPTO_GF128MUL=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +# CONFIG_CRYPTO_PCRYPT is not set +CONFIG_CRYPTO_WORKQUEUE=y +CONFIG_CRYPTO_CRYPTD=m +# CONFIG_CRYPTO_MCRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set +CONFIG_CRYPTO_ABLK_HELPER=m +CONFIG_CRYPTO_SIMD=m +CONFIG_CRYPTO_GLUE_HELPER_X86=m +CONFIG_CRYPTO_ENGINE=m + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_CHACHA20POLY1305 is not set +CONFIG_CRYPTO_SEQIV=y +# CONFIG_CRYPTO_ECHAINIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +CONFIG_CRYPTO_CTR=y +CONFIG_CRYPTO_CTS=y +CONFIG_CRYPTO_ECB=y +CONFIG_CRYPTO_LRW=m +# CONFIG_CRYPTO_PCBC is not set +CONFIG_CRYPTO_XTS=y +# CONFIG_CRYPTO_KEYWRAP is not set + +# +# Hash modes +# +CONFIG_CRYPTO_CMAC=m +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set +# CONFIG_CRYPTO_VMAC is not set + +# +# Digest +# +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CRC32C_INTEL=y +# CONFIG_CRYPTO_CRC32 is not set +CONFIG_CRYPTO_CRC32_PCLMUL=m +CONFIG_CRYPTO_CRCT10DIF=y +CONFIG_CRYPTO_CRCT10DIF_PCLMUL=m +# CONFIG_CRYPTO_GHASH is not set +# CONFIG_CRYPTO_POLY1305 is not set +# CONFIG_CRYPTO_POLY1305_X86_64 is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA1_SSSE3 is not set +# CONFIG_CRYPTO_SHA256_SSSE3 is not set +# CONFIG_CRYPTO_SHA512_SSSE3 is not set +# CONFIG_CRYPTO_SHA1_MB is not set +# CONFIG_CRYPTO_SHA256_MB is not set +# CONFIG_CRYPTO_SHA512_MB is not set +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_SHA512=y +# CONFIG_CRYPTO_SHA3 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set +CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL=m + +# +# Ciphers +# +CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_AES_TI is not set +CONFIG_CRYPTO_AES_X86_64=m +CONFIG_CRYPTO_AES_NI_INTEL=m +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_BLOWFISH_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA is not set +CONFIG_CRYPTO_CAMELLIA_X86_64=m +CONFIG_CRYPTO_CAMELLIA_AESNI_AVX_X86_64=m +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64 is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST5_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAST6 is not set +# CONFIG_CRYPTO_CAST6_AVX_X86_64 is not set +# CONFIG_CRYPTO_DES is not set +# CONFIG_CRYPTO_DES3_EDE_X86_64 is not set +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SALSA20_X86_64 is not set +# CONFIG_CRYPTO_CHACHA20 is not set +# CONFIG_CRYPTO_CHACHA20_X86_64 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_SERPENT_SSE2_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX2_X86_64 is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set +# CONFIG_CRYPTO_TWOFISH_X86_64 is not set +# CONFIG_CRYPTO_TWOFISH_X86_64_3WAY is not set +# CONFIG_CRYPTO_TWOFISH_AVX_X86_64 is not set + +# +# Compression +# +# CONFIG_CRYPTO_DEFLATE is not set +CONFIG_CRYPTO_LZO=y +# CONFIG_CRYPTO_842 is not set +# CONFIG_CRYPTO_LZ4 is not set +# CONFIG_CRYPTO_LZ4HC is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_HASH=y +CONFIG_CRYPTO_DRBG_CTR=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_JITTERENTROPY=y +# CONFIG_CRYPTO_USER_API_HASH is not set +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set +# CONFIG_CRYPTO_USER_API_RNG is not set +# CONFIG_CRYPTO_USER_API_AEAD is not set +CONFIG_CRYPTO_HASH_INFO=y +CONFIG_CRYPTO_HW=y +CONFIG_CRYPTO_DEV_PADLOCK=y +# CONFIG_CRYPTO_DEV_PADLOCK_AES is not set +# CONFIG_CRYPTO_DEV_PADLOCK_SHA is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API_DESC is not set +CONFIG_CRYPTO_DEV_CCP=y +# CONFIG_CRYPTO_DEV_CCP_DD is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCC is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXX is not set +# CONFIG_CRYPTO_DEV_QAT_C62X is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCCVF is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXXVF is not set +# CONFIG_CRYPTO_DEV_QAT_C62XVF is not set +CONFIG_CRYPTO_DEV_VIRTIO=m +CONFIG_ASYMMETRIC_KEY_TYPE=y +CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y +CONFIG_X509_CERTIFICATE_PARSER=y +CONFIG_PKCS7_MESSAGE_PARSER=y +# CONFIG_PKCS7_TEST_KEY is not set +CONFIG_SIGNED_PE_FILE_VERIFICATION=y + +# +# Certificates for signature checking +# +CONFIG_MODULE_SIG_KEY="certs/signing_key.pem" +CONFIG_SYSTEM_TRUSTED_KEYRING=y +CONFIG_SYSTEM_TRUSTED_KEYS="" +CONFIG_SYSTEM_EXTRA_CERTIFICATE=y +CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=4096 +CONFIG_SECONDARY_TRUSTED_KEYRING=y +CONFIG_HAVE_KVM=y +CONFIG_VIRTUALIZATION=y +# CONFIG_KVM is not set +# CONFIG_VHOST_NET is not set +# CONFIG_VHOST_VSOCK is not set +# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set +CONFIG_BINARY_PRINTF=y + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_HAVE_ARCH_BITREVERSE is not set +CONFIG_RATIONAL=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_NET_UTILS=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IO=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_HAS_FAST_MULTIPLIER=y +CONFIG_CRC_CCITT=y +CONFIG_CRC16=y +CONFIG_CRC_T10DIF=y +# CONFIG_CRC_ITU_T is not set +CONFIG_CRC32=y +# CONFIG_CRC32_SELFTEST is not set +CONFIG_CRC32_SLICEBY8=y +# CONFIG_CRC32_SLICEBY4 is not set +# CONFIG_CRC32_SARWATE is not set +# CONFIG_CRC32_BIT is not set +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +# CONFIG_CRC8 is not set +# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set +# CONFIG_RANDOM32_SELFTEST is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_XZ_DEC=y +CONFIG_XZ_DEC_X86=y +CONFIG_XZ_DEC_POWERPC=y +CONFIG_XZ_DEC_IA64=y +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_ARMTHUMB=y +CONFIG_XZ_DEC_SPARC=y +CONFIG_XZ_DEC_BCJ=y +# CONFIG_XZ_DEC_TEST is not set +CONFIG_DECOMPRESS_GZIP=y +CONFIG_DECOMPRESS_BZIP2=y +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DECOMPRESS_XZ=y +CONFIG_DECOMPRESS_LZO=y +CONFIG_DECOMPRESS_LZ4=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_RADIX_TREE_MULTIORDER=y +CONFIG_ASSOCIATIVE_ARRAY=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAS_DMA=y +# CONFIG_DMA_NOOP_OPS is not set +# CONFIG_DMA_VIRT_OPS is not set +CONFIG_CPU_RMAP=y +CONFIG_DQL=y +CONFIG_GLOB=y +# CONFIG_GLOB_SELFTEST is not set +CONFIG_NLATTR=y +CONFIG_CLZ_TAB=y +# CONFIG_CORDIC is not set +CONFIG_DDR=y +CONFIG_IRQ_POLL=y +CONFIG_MPILIB=y +CONFIG_SIGNATURE=y +CONFIG_OID_REGISTRY=y +CONFIG_UCS2_STRING=y +CONFIG_FONT_SUPPORT=y +# CONFIG_FONTS is not set +CONFIG_FONT_8x8=y +CONFIG_FONT_8x16=y +# CONFIG_SG_SPLIT is not set +CONFIG_SG_POOL=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_PMEM_API=y +CONFIG_ARCH_HAS_MMIO_FLUSH=y +CONFIG_SBITMAP=y diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/instructions.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/instructions.md new file mode 100755 index 0000000..cfe36f2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/instructions.md @@ -0,0 +1,42 @@ +1. Clone Linus’ repo and read Installing the kernel source: +``` +$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git +``` + +2. Generate .config and add CONFIG_LOCALVERSION_AUTO=y +``` +$ make localmodconfig +``` + +3. Get an openssl header error, install lots of dev libraries +``` +$ sudo apt-get install python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev zlib1g-dev +``` + +4. Make! (It takes ~ 30 min) +``` +$ make +``` + +5. Make module, install, add to grub +``` +$ make modules +$ sudo make modules_install +$ sudo make install +$ update-grub +``` + +6. Reboot machine. For ubuntu: press shift to get grub menu + +Profit! + +Some tips: +* List of kernel addresses sorted in ascending order, from which it is simple to find the function that contains the offending address: +``` +$ nm vmlinux | sort | less +``` + +Send +``` +make && make modules && make modules_install && make install +``` diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/readme.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/readme.md new file mode 100644 index 0000000..8ca0257 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/bt3/task_02/readme.md @@ -0,0 +1,34 @@ +This is Task 02 of the Eudyptula Challenge +------------------------------------------ + +Now that you have written your first kernel module, it's time to take +off the training wheels and move on to building a custom kernel. No +more distro kernels for you. For this task you must run your own +kernel. And use git! Exciting, isn't it? No? Oh, ok... + +The tasks for this round are: + - Download Linus's latest git tree from git.kernel.org (you have to + figure out which one is his. It's not that hard, just remember what + his last name is and you should be fine.) + - Build it, install it, and boot it. You can use whatever kernel + configuration options you wish to use, but you must enable + CONFIG_LOCALVERSION_AUTO=y. + - Show proof of booting this kernel. Bonus points if you do it on a + "real" machine, and not a virtual machine (virtual machines are + acceptable, but come on, real kernel developers don't mess around + with virtual machines, they are too slow. Oh yeah, we aren't real + kernel developers just yet. Well, I'm not anyway, I'm just a + script...) Again, proof of running this kernel is up to you, I'm + sure you can do well. + +Hint, you should look into the 'make localmodconfig' option, and base +your kernel configuration on a working distro kernel configuration. +Don't sit there and answer all 1625 different kernel configuration +options by hand, even I, a foolish script, know better than to do that! + +After doing this, don't throw away that kernel, git tree, and +configuration file. You'll be using it for later tasks. A working +kernel configuration file is a precious thing, all kernel developers +have one they have grown and tended to over the years. This is the +start of a long journey with yours. Don't discard it like was a broken +umbrella, it deserves better than that. diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_01/Makefile b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_01/Makefile new file mode 100644 index 0000000..e05c3b6 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_01/Makefile @@ -0,0 +1,8 @@ +KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build +obj-m += task-01.o + +all: + make -C $(KERNEL_SRC) M=$(PWD) modules + +clean: + make -C $(KERNEL_SRC) M=$(PWD) clean diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_01/task-01.c b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_01/task-01.c new file mode 100644 index 0000000..98ec6d0 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_01/task-01.c @@ -0,0 +1,15 @@ +#include +#include +#include + +static int __init setup(void) { + printk(KERN_DEBUG "Hello World!"); + + return 0; +} + +static void __exit teardown(void) { +} + +module_init(setup); +module_exit(teardown); diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_02/.config b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_02/.config new file mode 100644 index 0000000..818fce2 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_02/.config @@ -0,0 +1,4753 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/x86 4.11.0-rc4 Kernel Configuration +# +CONFIG_64BIT=y +CONFIG_X86_64=y +CONFIG_X86=y +CONFIG_INSTRUCTION_DECODER=y +CONFIG_OUTPUT_FORMAT="elf64-x86-64" +CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig" +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_MMU=y +CONFIG_ARCH_MMAP_RND_BITS_MIN=28 +CONFIG_ARCH_MMAP_RND_BITS_MAX=32 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y +CONFIG_GENERIC_HWEIGHT=y +CONFIG_ARCH_MAY_HAVE_PC_FDC=y +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_ARCH_HAS_CPU_RELAX=y +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y +CONFIG_HAVE_SETUP_PER_CPU_AREA=y +CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y +CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ZONE_DMA32=y +CONFIG_AUDIT_ARCH=y +CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y +CONFIG_HAVE_INTEL_TXT=y +CONFIG_X86_64_SMP=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_PGTABLE_LEVELS=4 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +CONFIG_IRQ_WORK=y +CONFIG_BUILDTIME_EXTABLE_SORT=y +CONFIG_THREAD_INFO_IN_TASK=y + +# +# General setup +# +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_CROSS_COMPILE="" +# CONFIG_COMPILE_TEST is not set +CONFIG_LOCALVERSION="-Hai" +CONFIG_LOCALVERSION_AUTO=y +CONFIG_HAVE_KERNEL_GZIP=y +CONFIG_HAVE_KERNEL_BZIP2=y +CONFIG_HAVE_KERNEL_LZMA=y +CONFIG_HAVE_KERNEL_XZ=y +CONFIG_HAVE_KERNEL_LZO=y +CONFIG_HAVE_KERNEL_LZ4=y +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +# CONFIG_KERNEL_XZ is not set +# CONFIG_KERNEL_LZO is not set +# CONFIG_KERNEL_LZ4 is not set +CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +CONFIG_POSIX_MQUEUE_SYSCTL=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_FHANDLE=y +CONFIG_USELIB=y +CONFIG_AUDIT=y +CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_AUDITSYSCALL=y +CONFIG_AUDIT_WATCH=y +CONFIG_AUDIT_TREE=y + +# +# IRQ subsystem +# +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_PENDING_IRQ=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +# CONFIG_IRQ_DOMAIN_DEBUG is not set +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_SPARSE_IRQ=y +CONFIG_CLOCKSOURCE_WATCHDOG=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y +CONFIG_GENERIC_CMOS_UPDATE=y + +# +# Timers subsystem +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ_COMMON=y +# CONFIG_HZ_PERIODIC is not set +CONFIG_NO_HZ_IDLE=y +# CONFIG_NO_HZ_FULL is not set +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y + +# +# CPU/Task time and stats accounting +# +CONFIG_TICK_CPU_ACCOUNTING=y +# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set +# CONFIG_IRQ_TIME_ACCOUNTING is not set +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_BSD_PROCESS_ACCT_V3=y +CONFIG_TASKSTATS=y +CONFIG_TASK_DELAY_ACCT=y +CONFIG_TASK_XACCT=y +CONFIG_TASK_IO_ACCOUNTING=y + +# +# RCU Subsystem +# +CONFIG_TREE_RCU=y +# CONFIG_RCU_EXPERT is not set +CONFIG_SRCU=y +# CONFIG_TASKS_RCU is not set +CONFIG_RCU_STALL_COMMON=y +# CONFIG_TREE_RCU_TRACE is not set +CONFIG_BUILD_BIN2C=y +CONFIG_IKCONFIG=m +# CONFIG_IKCONFIG_PROC is not set +CONFIG_LOG_BUF_SHIFT=18 +CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13 +CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y +CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y +CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y +CONFIG_ARCH_SUPPORTS_INT128=y +CONFIG_NUMA_BALANCING=y +CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y +CONFIG_CGROUPS=y +CONFIG_PAGE_COUNTER=y +CONFIG_MEMCG=y +CONFIG_MEMCG_SWAP=y +# CONFIG_MEMCG_SWAP_ENABLED is not set +CONFIG_BLK_CGROUP=y +# CONFIG_DEBUG_BLK_CGROUP is not set +CONFIG_CGROUP_WRITEBACK=y +CONFIG_CGROUP_SCHED=y +CONFIG_FAIR_GROUP_SCHED=y +CONFIG_CFS_BANDWIDTH=y +# CONFIG_RT_GROUP_SCHED is not set +CONFIG_CGROUP_PIDS=y +# CONFIG_CGROUP_RDMA is not set +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_HUGETLB=y +CONFIG_CPUSETS=y +CONFIG_PROC_PID_CPUSET=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_PERF=y +# CONFIG_CGROUP_BPF is not set +# CONFIG_CGROUP_DEBUG is not set +CONFIG_SOCK_CGROUP_DATA=y +CONFIG_CHECKPOINT_RESTORE=y +CONFIG_NAMESPACES=y +CONFIG_UTS_NS=y +CONFIG_IPC_NS=y +CONFIG_USER_NS=y +CONFIG_PID_NS=y +CONFIG_NET_NS=y +CONFIG_SCHED_AUTOGROUP=y +# CONFIG_SYSFS_DEPRECATED is not set +CONFIG_RELAY=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_RD_GZIP=y +CONFIG_RD_BZIP2=y +CONFIG_RD_LZMA=y +CONFIG_RD_XZ=y +CONFIG_RD_LZO=y +CONFIG_RD_LZ4=y +CONFIG_INITRAMFS_COMPRESSION=".gz" +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +CONFIG_HAVE_UID16=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_HAVE_PCSPKR_PLATFORM=y +CONFIG_BPF=y +CONFIG_EXPERT=y +CONFIG_UID16=y +CONFIG_MULTIUSER=y +CONFIG_SGETMASK_SYSCALL=y +CONFIG_SYSFS_SYSCALL=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_POSIX_TIMERS=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_ALL=y +CONFIG_KALLSYMS_ABSOLUTE_PERCPU=y +CONFIG_KALLSYMS_BASE_RELATIVE=y +CONFIG_PRINTK=y +CONFIG_PRINTK_NMI=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_PCSPKR_PLATFORM=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_BPF_SYSCALL=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_ADVISE_SYSCALLS=y +CONFIG_USERFAULTFD=y +CONFIG_PCI_QUIRKS=y +CONFIG_MEMBARRIER=y +# CONFIG_EMBEDDED is not set +CONFIG_HAVE_PERF_EVENTS=y +# CONFIG_PC104 is not set + +# +# Kernel Performance Events And Counters +# +CONFIG_PERF_EVENTS=y +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +# CONFIG_SLUB_MEMCG_SYSFS_ON is not set +# CONFIG_COMPAT_BRK is not set +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +CONFIG_SLAB_FREELIST_RANDOM=y +CONFIG_SLUB_CPU_PARTIAL=y +CONFIG_SYSTEM_DATA_VERIFICATION=y +CONFIG_PROFILING=y +CONFIG_TRACEPOINTS=y +CONFIG_KEXEC_CORE=y +# CONFIG_OPROFILE is not set +CONFIG_HAVE_OPROFILE=y +CONFIG_OPROFILE_NMI_TIMER=y +CONFIG_KPROBES=y +CONFIG_JUMP_LABEL=y +# CONFIG_STATIC_KEYS_SELFTEST is not set +CONFIG_OPTPROBES=y +CONFIG_KPROBES_ON_FTRACE=y +# CONFIG_UPROBES is not set +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_KRETPROBES=y +CONFIG_HAVE_IOREMAP_PROT=y +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_KPROBES_ON_FTRACE=y +CONFIG_HAVE_NMI=y +CONFIG_HAVE_ARCH_TRACEHOOK=y +CONFIG_HAVE_DMA_CONTIGUOUS=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_CLK=y +CONFIG_HAVE_DMA_API_DEBUG=y +CONFIG_HAVE_HW_BREAKPOINT=y +CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y +CONFIG_HAVE_USER_RETURN_NOTIFIER=y +CONFIG_HAVE_PERF_EVENTS_NMI=y +CONFIG_HAVE_PERF_REGS=y +CONFIG_HAVE_PERF_USER_STACK_DUMP=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y +CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y +CONFIG_HAVE_CMPXCHG_LOCAL=y +CONFIG_HAVE_CMPXCHG_DOUBLE=y +CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y +CONFIG_ARCH_WANT_OLD_COMPAT_IPC=y +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_SECCOMP_FILTER=y +CONFIG_HAVE_GCC_PLUGINS=y +# CONFIG_GCC_PLUGINS is not set +CONFIG_HAVE_CC_STACKPROTECTOR=y +CONFIG_CC_STACKPROTECTOR=y +# CONFIG_CC_STACKPROTECTOR_NONE is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y +CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES=y +CONFIG_HAVE_CONTEXT_TRACKING=y +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y +CONFIG_HAVE_ARCH_HUGE_VMAP=y +CONFIG_HAVE_ARCH_SOFT_DIRTY=y +CONFIG_MODULES_USE_ELF_RELA=y +CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_HAVE_ARCH_MMAP_RND_BITS=y +CONFIG_HAVE_EXIT_THREAD=y +CONFIG_ARCH_MMAP_RND_BITS=28 +CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y +CONFIG_ARCH_MMAP_RND_COMPAT_BITS=8 +CONFIG_HAVE_COPY_THREAD_TLS=y +CONFIG_HAVE_STACK_VALIDATION=y +# CONFIG_HAVE_ARCH_HASH is not set +CONFIG_ISA_BUS_API=y +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_COMPAT_OLD_SIGACTION=y +# CONFIG_CPU_NO_EFFICIENT_FFS is not set +CONFIG_HAVE_ARCH_VMAP_STACK=y +CONFIG_VMAP_STACK=y +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX is not set +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_STRICT_MODULE_RWX=y + +# +# GCOV-based kernel profiling +# +# CONFIG_GCOV_KERNEL is not set +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_MODVERSIONS=y +CONFIG_MODULE_SRCVERSION_ALL=y +CONFIG_MODULE_SIG=y +# CONFIG_MODULE_SIG_FORCE is not set +CONFIG_MODULE_SIG_ALL=y +# CONFIG_MODULE_SIG_SHA1 is not set +# CONFIG_MODULE_SIG_SHA224 is not set +# CONFIG_MODULE_SIG_SHA256 is not set +# CONFIG_MODULE_SIG_SHA384 is not set +CONFIG_MODULE_SIG_SHA512=y +CONFIG_MODULE_SIG_HASH="sha512" +# CONFIG_MODULE_COMPRESS is not set +CONFIG_MODULES_TREE_LOOKUP=y +CONFIG_BLOCK=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_BSGLIB=y +CONFIG_BLK_DEV_INTEGRITY=y +# CONFIG_BLK_DEV_ZONED is not set +CONFIG_BLK_DEV_THROTTLING=y +CONFIG_BLK_CMDLINE_PARSER=y +# CONFIG_BLK_WBT is not set +CONFIG_BLK_DEBUG_FS=y +# CONFIG_BLK_SED_OPAL is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +CONFIG_AIX_PARTITION=y +CONFIG_OSF_PARTITION=y +CONFIG_AMIGA_PARTITION=y +CONFIG_ATARI_PARTITION=y +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +CONFIG_LDM_PARTITION=y +# CONFIG_LDM_DEBUG is not set +CONFIG_SGI_PARTITION=y +CONFIG_ULTRIX_PARTITION=y +CONFIG_SUN_PARTITION=y +CONFIG_KARMA_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_SYSV68_PARTITION=y +CONFIG_CMDLINE_PARTITION=y +CONFIG_BLOCK_COMPAT=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_MQ_VIRTIO=y + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +CONFIG_CFQ_GROUP_IOSCHED=y +CONFIG_DEFAULT_DEADLINE=y +# CONFIG_DEFAULT_CFQ is not set +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="deadline" +CONFIG_MQ_IOSCHED_DEADLINE=y +CONFIG_ASN1=y +CONFIG_INLINE_SPIN_UNLOCK_IRQ=y +CONFIG_INLINE_READ_UNLOCK=y +CONFIG_INLINE_READ_UNLOCK_IRQ=y +CONFIG_INLINE_WRITE_UNLOCK=y +CONFIG_INLINE_WRITE_UNLOCK_IRQ=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y +CONFIG_QUEUED_SPINLOCKS=y +CONFIG_ARCH_USE_QUEUED_RWLOCKS=y +CONFIG_QUEUED_RWLOCKS=y +CONFIG_FREEZER=y + +# +# Processor type and features +# +CONFIG_ZONE_DMA=y +CONFIG_SMP=y +CONFIG_X86_FEATURE_NAMES=y +CONFIG_X86_FAST_FEATURE_TESTS=y +CONFIG_X86_X2APIC=y +CONFIG_X86_MPPARSE=y +# CONFIG_GOLDFISH is not set +# CONFIG_INTEL_RDT_A is not set +CONFIG_X86_EXTENDED_PLATFORM=y +CONFIG_X86_NUMACHIP=y +# CONFIG_X86_VSMP is not set +# CONFIG_X86_UV is not set +# CONFIG_X86_GOLDFISH is not set +# CONFIG_X86_INTEL_MID is not set +CONFIG_X86_INTEL_LPSS=y +CONFIG_X86_AMD_PLATFORM_DEVICE=y +CONFIG_IOSF_MBI=y +CONFIG_IOSF_MBI_DEBUG=y +CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y +CONFIG_SCHED_OMIT_FRAME_POINTER=y +CONFIG_HYPERVISOR_GUEST=y +CONFIG_PARAVIRT=y +# CONFIG_PARAVIRT_DEBUG is not set +CONFIG_PARAVIRT_SPINLOCKS=y +# CONFIG_QUEUED_LOCK_STAT is not set +CONFIG_XEN=y +CONFIG_XEN_DOM0=y +CONFIG_XEN_PVHVM=y +CONFIG_XEN_512GB=y +CONFIG_XEN_SAVE_RESTORE=y +# CONFIG_XEN_DEBUG_FS is not set +CONFIG_XEN_PVH=y +CONFIG_KVM_GUEST=y +CONFIG_KVM_DEBUG_FS=y +# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set +CONFIG_PARAVIRT_CLOCK=y +CONFIG_NO_BOOTMEM=y +# CONFIG_MK8 is not set +# CONFIG_MPSC is not set +# CONFIG_MCORE2 is not set +# CONFIG_MATOM is not set +CONFIG_GENERIC_CPU=y +CONFIG_X86_INTERNODE_CACHE_SHIFT=6 +CONFIG_X86_L1_CACHE_SHIFT=6 +CONFIG_X86_TSC=y +CONFIG_X86_CMPXCHG64=y +CONFIG_X86_CMOV=y +CONFIG_X86_MINIMUM_CPU_FAMILY=64 +CONFIG_X86_DEBUGCTLMSR=y +CONFIG_PROCESSOR_SELECT=y +CONFIG_CPU_SUP_INTEL=y +CONFIG_CPU_SUP_AMD=y +CONFIG_CPU_SUP_CENTAUR=y +CONFIG_HPET_TIMER=y +CONFIG_HPET_EMULATE_RTC=y +CONFIG_DMI=y +CONFIG_GART_IOMMU=y +CONFIG_CALGARY_IOMMU=y +CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT=y +CONFIG_SWIOTLB=y +CONFIG_IOMMU_HELPER=y +# CONFIG_MAXSMP is not set +CONFIG_NR_CPUS=256 +CONFIG_SCHED_SMT=y +CONFIG_SCHED_MC=y +CONFIG_SCHED_MC_PRIO=y +# CONFIG_PREEMPT_NONE is not set +CONFIG_PREEMPT_VOLUNTARY=y +# CONFIG_PREEMPT is not set +CONFIG_X86_LOCAL_APIC=y +CONFIG_X86_IO_APIC=y +CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y +CONFIG_X86_MCE=y +CONFIG_X86_MCE_INTEL=y +CONFIG_X86_MCE_AMD=y +CONFIG_X86_MCE_THRESHOLD=y +# CONFIG_X86_MCE_INJECT is not set +CONFIG_X86_THERMAL_VECTOR=y + +# +# Performance monitoring +# +CONFIG_PERF_EVENTS_INTEL_UNCORE=y +CONFIG_PERF_EVENTS_INTEL_RAPL=m +# CONFIG_PERF_EVENTS_INTEL_CSTATE is not set +# CONFIG_PERF_EVENTS_AMD_POWER is not set +# CONFIG_VM86 is not set +CONFIG_X86_16BIT=y +CONFIG_X86_ESPFIX64=y +CONFIG_X86_VSYSCALL_EMULATION=y +# CONFIG_I8K is not set +CONFIG_MICROCODE=y +CONFIG_MICROCODE_INTEL=y +CONFIG_MICROCODE_AMD=y +CONFIG_MICROCODE_OLD_INTERFACE=y +# CONFIG_X86_MSR is not set +# CONFIG_X86_CPUID is not set +CONFIG_ARCH_PHYS_ADDR_T_64BIT=y +CONFIG_ARCH_DMA_ADDR_T_64BIT=y +CONFIG_X86_DIRECT_GBPAGES=y +CONFIG_NUMA=y +CONFIG_AMD_NUMA=y +CONFIG_X86_64_ACPI_NUMA=y +CONFIG_NODES_SPAN_OTHER_NODES=y +# CONFIG_NUMA_EMU is not set +CONFIG_NODES_SHIFT=6 +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_SPARSEMEM_DEFAULT=y +CONFIG_ARCH_SELECT_MEMORY_MODEL=y +CONFIG_ARCH_MEMORY_PROBE=y +CONFIG_ARCH_PROC_KCORE_TEXT=y +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_SPARSEMEM_MANUAL=y +CONFIG_SPARSEMEM=y +CONFIG_NEED_MULTIPLE_NODES=y +CONFIG_HAVE_MEMORY_PRESENT=y +CONFIG_SPARSEMEM_EXTREME=y +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y +CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER=y +CONFIG_SPARSEMEM_VMEMMAP=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MEMBLOCK_NODE_MAP=y +CONFIG_ARCH_DISCARD_MEMBLOCK=y +CONFIG_MEMORY_ISOLATION=y +CONFIG_MOVABLE_NODE=y +CONFIG_HAVE_BOOTMEM_INFO_NODE=y +CONFIG_MEMORY_HOTPLUG=y +CONFIG_MEMORY_HOTPLUG_SPARSE=y +CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y +CONFIG_MEMORY_HOTREMOVE=y +CONFIG_SPLIT_PTLOCK_CPUS=4 +CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y +CONFIG_MEMORY_BALLOON=y +CONFIG_BALLOON_COMPACTION=y +CONFIG_COMPACTION=y +CONFIG_MIGRATION=y +CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION=y +CONFIG_PHYS_ADDR_T_64BIT=y +CONFIG_BOUNCE=y +CONFIG_VIRT_TO_BUS=y +CONFIG_MMU_NOTIFIER=y +CONFIG_KSM=y +CONFIG_DEFAULT_MMAP_MIN_ADDR=65536 +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y +CONFIG_MEMORY_FAILURE=y +# CONFIG_HWPOISON_INJECT is not set +CONFIG_TRANSPARENT_HUGEPAGE=y +CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y +# CONFIG_TRANSPARENT_HUGEPAGE_MADVISE is not set +CONFIG_TRANSPARENT_HUGE_PAGECACHE=y +CONFIG_CLEANCACHE=y +CONFIG_FRONTSWAP=y +CONFIG_CMA=y +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_AREAS=7 +CONFIG_MEM_SOFT_DIRTY=y +CONFIG_ZSWAP=y +CONFIG_ZPOOL=y +CONFIG_ZBUD=y +# CONFIG_Z3FOLD is not set +CONFIG_ZSMALLOC=y +CONFIG_PGTABLE_MAPPING=y +# CONFIG_ZSMALLOC_STAT is not set +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT=y +# CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set +CONFIG_IDLE_PAGE_TRACKING=y +CONFIG_ZONE_DEVICE=y +CONFIG_ARCH_USES_HIGH_VMA_FLAGS=y +CONFIG_ARCH_HAS_PKEYS=y +CONFIG_X86_PMEM_LEGACY_DEVICE=y +CONFIG_X86_PMEM_LEGACY=y +CONFIG_X86_CHECK_BIOS_CORRUPTION=y +CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK=y +CONFIG_X86_RESERVE_LOW=64 +CONFIG_MTRR=y +CONFIG_MTRR_SANITIZER=y +CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=1 +CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1 +CONFIG_X86_PAT=y +CONFIG_ARCH_USES_PG_UNCACHED=y +CONFIG_ARCH_RANDOM=y +CONFIG_X86_SMAP=y +CONFIG_X86_INTEL_MPX=y +CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y +CONFIG_EFI=y +CONFIG_EFI_STUB=y +CONFIG_EFI_MIXED=y +CONFIG_SECCOMP=y +# CONFIG_HZ_100 is not set +CONFIG_HZ_250=y +# CONFIG_HZ_300 is not set +# CONFIG_HZ_1000 is not set +CONFIG_HZ=250 +CONFIG_SCHED_HRTICK=y +CONFIG_KEXEC=y +CONFIG_KEXEC_FILE=y +CONFIG_KEXEC_VERIFY_SIG=y +CONFIG_KEXEC_BZIMAGE_VERIFY_SIG=y +CONFIG_CRASH_DUMP=y +CONFIG_KEXEC_JUMP=y +CONFIG_PHYSICAL_START=0x1000000 +CONFIG_RELOCATABLE=y +CONFIG_RANDOMIZE_BASE=y +CONFIG_X86_NEED_RELOCS=y +CONFIG_PHYSICAL_ALIGN=0x200000 +CONFIG_RANDOMIZE_MEMORY=y +CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING=0xa +CONFIG_HOTPLUG_CPU=y +# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set +# CONFIG_DEBUG_HOTPLUG_CPU0 is not set +# CONFIG_COMPAT_VDSO is not set +# CONFIG_LEGACY_VSYSCALL_NATIVE is not set +CONFIG_LEGACY_VSYSCALL_EMULATE=y +# CONFIG_LEGACY_VSYSCALL_NONE is not set +# CONFIG_CMDLINE_BOOL is not set +CONFIG_MODIFY_LDT_SYSCALL=y +CONFIG_HAVE_LIVEPATCH=y +CONFIG_LIVEPATCH=y +CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y +CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y +CONFIG_USE_PERCPU_NUMA_NODE_ID=y + +# +# Power management and ACPI options +# +CONFIG_ARCH_HIBERNATION_HEADER=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_SUSPEND_SKIP_SYNC is not set +CONFIG_HIBERNATE_CALLBACKS=y +CONFIG_HIBERNATION=y +CONFIG_PM_STD_PARTITION="" +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +# CONFIG_PM_AUTOSLEEP is not set +CONFIG_PM_WAKELOCKS=y +CONFIG_PM_WAKELOCKS_LIMIT=100 +CONFIG_PM_WAKELOCKS_GC=y +CONFIG_PM=y +CONFIG_PM_DEBUG=y +CONFIG_PM_ADVANCED_DEBUG=y +# CONFIG_PM_TEST_SUSPEND is not set +CONFIG_PM_SLEEP_DEBUG=y +# CONFIG_DPM_WATCHDOG is not set +CONFIG_PM_TRACE=y +CONFIG_PM_TRACE_RTC=y +CONFIG_PM_CLK=y +CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y +CONFIG_ACPI=y +CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y +CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y +CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y +# CONFIG_ACPI_DEBUGGER is not set +CONFIG_ACPI_SLEEP=y +# CONFIG_ACPI_PROCFS_POWER is not set +CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y +# CONFIG_ACPI_EC_DEBUGFS is not set +CONFIG_ACPI_AC=y +CONFIG_ACPI_BATTERY=y +CONFIG_ACPI_BUTTON=y +# CONFIG_ACPI_VIDEO is not set +CONFIG_ACPI_FAN=y +CONFIG_ACPI_DOCK=y +CONFIG_ACPI_CPU_FREQ_PSS=y +CONFIG_ACPI_PROCESSOR_CSTATE=y +CONFIG_ACPI_PROCESSOR_IDLE=y +CONFIG_ACPI_CPPC_LIB=y +CONFIG_ACPI_PROCESSOR=y +CONFIG_ACPI_HOTPLUG_CPU=y +# CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set +CONFIG_ACPI_THERMAL=y +CONFIG_ACPI_NUMA=y +CONFIG_ACPI_CUSTOM_DSDT_FILE="" +# CONFIG_ACPI_CUSTOM_DSDT is not set +CONFIG_ARCH_HAS_ACPI_TABLE_UPGRADE=y +CONFIG_ACPI_TABLE_UPGRADE=y +# CONFIG_ACPI_DEBUG is not set +CONFIG_ACPI_PCI_SLOT=y +CONFIG_X86_PM_TIMER=y +CONFIG_ACPI_CONTAINER=y +CONFIG_ACPI_HOTPLUG_MEMORY=y +CONFIG_ACPI_HOTPLUG_IOAPIC=y +# CONFIG_ACPI_SBS is not set +CONFIG_ACPI_HED=y +# CONFIG_ACPI_CUSTOM_METHOD is not set +CONFIG_ACPI_BGRT=y +# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set +CONFIG_ACPI_NFIT=m +# CONFIG_ACPI_NFIT_DEBUG is not set +CONFIG_HAVE_ACPI_APEI=y +CONFIG_HAVE_ACPI_APEI_NMI=y +CONFIG_ACPI_APEI=y +CONFIG_ACPI_APEI_GHES=y +CONFIG_ACPI_APEI_PCIEAER=y +CONFIG_ACPI_APEI_MEMORY_FAILURE=y +# CONFIG_ACPI_APEI_EINJ is not set +# CONFIG_ACPI_APEI_ERST_DEBUG is not set +# CONFIG_DPTF_POWER is not set +# CONFIG_ACPI_EXTLOG is not set +# CONFIG_PMIC_OPREGION is not set +# CONFIG_ACPI_CONFIGFS is not set +CONFIG_SFI=y + +# +# CPU Frequency scaling +# +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set + +# +# CPU frequency scaling drivers +# +CONFIG_X86_INTEL_PSTATE=y +CONFIG_X86_PCC_CPUFREQ=y +CONFIG_X86_ACPI_CPUFREQ=y +CONFIG_X86_ACPI_CPUFREQ_CPB=y +CONFIG_X86_POWERNOW_K8=y +# CONFIG_X86_AMD_FREQ_SENSITIVITY is not set +CONFIG_X86_SPEEDSTEP_CENTRINO=y +# CONFIG_X86_P4_CLOCKMOD is not set + +# +# shared options +# +# CONFIG_X86_SPEEDSTEP_LIB is not set + +# +# CPU Idle +# +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_IDLE_GOV_MENU=y +# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set +CONFIG_INTEL_IDLE=y + +# +# Bus options (PCI etc.) +# +CONFIG_PCI=y +CONFIG_PCI_DIRECT=y +CONFIG_PCI_MMCONFIG=y +CONFIG_PCI_XEN=y +CONFIG_PCI_DOMAINS=y +# CONFIG_PCI_CNB20LE_QUIRK is not set +CONFIG_PCIEPORTBUS=y +CONFIG_HOTPLUG_PCI_PCIE=y +CONFIG_PCIEAER=y +# CONFIG_PCIE_ECRC is not set +# CONFIG_PCIEAER_INJECT is not set +CONFIG_PCIEASPM=y +CONFIG_PCIEASPM_DEBUG=y +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +# CONFIG_PCIEASPM_PERFORMANCE is not set +CONFIG_PCIE_PME=y +CONFIG_PCIE_DPC=y +# CONFIG_PCIE_PTM is not set +CONFIG_PCI_BUS_ADDR_T_64BIT=y +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +# CONFIG_PCI_DEBUG is not set +CONFIG_PCI_REALLOC_ENABLE_AUTO=y +# CONFIG_PCI_STUB is not set +# CONFIG_XEN_PCIDEV_FRONTEND is not set +CONFIG_HT_IRQ=y +CONFIG_PCI_ATS=y +CONFIG_PCI_IOV=y +CONFIG_PCI_PRI=y +CONFIG_PCI_PASID=y +CONFIG_PCI_LABEL=y +CONFIG_HOTPLUG_PCI=y +CONFIG_HOTPLUG_PCI_ACPI=y +# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set +CONFIG_HOTPLUG_PCI_CPCI=y +# CONFIG_HOTPLUG_PCI_CPCI_ZT5550 is not set +# CONFIG_HOTPLUG_PCI_CPCI_GENERIC is not set +CONFIG_HOTPLUG_PCI_SHPC=m + +# +# DesignWare PCI Core Support +# +CONFIG_PCIE_DW=y +CONFIG_PCIE_DW_HOST=y +CONFIG_PCIE_DW_PLAT=y + +# +# PCI host controller drivers +# +# CONFIG_VMD is not set +CONFIG_ISA_BUS=y +CONFIG_ISA_DMA_API=y +CONFIG_AMD_NB=y +# CONFIG_PCCARD is not set +CONFIG_RAPIDIO=y +# CONFIG_RAPIDIO_TSI721 is not set +CONFIG_RAPIDIO_DISC_TIMEOUT=30 +# CONFIG_RAPIDIO_ENABLE_RX_TX_PORTS is not set +CONFIG_RAPIDIO_DMA_ENGINE=y +# CONFIG_RAPIDIO_DEBUG is not set +# CONFIG_RAPIDIO_ENUM_BASIC is not set +# CONFIG_RAPIDIO_CHMAN is not set +# CONFIG_RAPIDIO_MPORT_CDEV is not set + +# +# RapidIO Switch drivers +# +# CONFIG_RAPIDIO_TSI57X is not set +# CONFIG_RAPIDIO_CPS_XX is not set +# CONFIG_RAPIDIO_TSI568 is not set +# CONFIG_RAPIDIO_CPS_GEN2 is not set +# CONFIG_RAPIDIO_RXS_GEN3 is not set +# CONFIG_X86_SYSFB is not set + +# +# Executable file formats / Emulations +# +CONFIG_BINFMT_ELF=y +CONFIG_COMPAT_BINFMT_ELF=y +CONFIG_ELFCORE=y +CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y +CONFIG_BINFMT_SCRIPT=y +# CONFIG_HAVE_AOUT is not set +# CONFIG_BINFMT_MISC is not set +CONFIG_COREDUMP=y +CONFIG_IA32_EMULATION=y +# CONFIG_IA32_AOUT is not set +CONFIG_X86_X32=y +CONFIG_COMPAT_32=y +CONFIG_COMPAT=y +CONFIG_COMPAT_FOR_U64_ALIGNMENT=y +CONFIG_SYSVIPC_COMPAT=y +CONFIG_KEYS_COMPAT=y +CONFIG_X86_DEV_DMA_OPS=y +CONFIG_NET=y +CONFIG_NET_INGRESS=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +CONFIG_UNIX=y +# CONFIG_UNIX_DIAG is not set +# CONFIG_XFRM_USER is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_FIB_TRIE_STATS=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +# CONFIG_IP_PNP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE_DEMUX is not set +# CONFIG_NET_IP_TUNNEL is not set +CONFIG_IP_MROUTE=y +# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set +CONFIG_IP_PIMSM_V1=y +CONFIG_IP_PIMSM_V2=y +CONFIG_SYN_COOKIES=y +# CONFIG_NET_UDP_TUNNEL is not set +# CONFIG_NET_FOU is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +# CONFIG_INET_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_DIAG is not set +CONFIG_TCP_CONG_ADVANCED=y +# CONFIG_TCP_CONG_BIC is not set +CONFIG_TCP_CONG_CUBIC=y +# CONFIG_TCP_CONG_WESTWOOD is not set +# CONFIG_TCP_CONG_HTCP is not set +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_NV is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_TCP_CONG_LP is not set +# CONFIG_TCP_CONG_VENO is not set +# CONFIG_TCP_CONG_YEAH is not set +# CONFIG_TCP_CONG_ILLINOIS is not set +# CONFIG_TCP_CONG_DCTCP is not set +# CONFIG_TCP_CONG_CDG is not set +# CONFIG_TCP_CONG_BBR is not set +CONFIG_DEFAULT_CUBIC=y +# CONFIG_DEFAULT_RENO is not set +CONFIG_DEFAULT_TCP_CONG="cubic" +CONFIG_TCP_MD5SIG=y +CONFIG_IPV6=y +CONFIG_IPV6_ROUTER_PREF=y +CONFIG_IPV6_ROUTE_INFO=y +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_IPV6_ILA is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET6_XFRM_MODE_TUNNEL is not set +# CONFIG_INET6_XFRM_MODE_BEET is not set +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +# CONFIG_IPV6_SIT is not set +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_FOU is not set +# CONFIG_IPV6_FOU_TUNNEL is not set +CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_IPV6_SUBTREES=y +CONFIG_IPV6_MROUTE=y +CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y +CONFIG_IPV6_PIMSM_V2=y +# CONFIG_IPV6_SEG6_LWTUNNEL is not set +# CONFIG_IPV6_SEG6_HMAC is not set +CONFIG_NETLABEL=y +CONFIG_NETWORK_SECMARK=y +# CONFIG_NET_PTP_CLASSIFY is not set +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set +CONFIG_NETFILTER=y +# CONFIG_NETFILTER_DEBUG is not set +CONFIG_NETFILTER_ADVANCED=y + +# +# Core Netfilter Configuration +# +CONFIG_NETFILTER_INGRESS=y +# CONFIG_NETFILTER_NETLINK_ACCT is not set +# CONFIG_NETFILTER_NETLINK_QUEUE is not set +# CONFIG_NETFILTER_NETLINK_LOG is not set +# CONFIG_NF_CONNTRACK is not set +# CONFIG_NF_LOG_NETDEV is not set +# CONFIG_NF_TABLES is not set +CONFIG_NETFILTER_XTABLES=m + +# +# Xtables combined modules +# +# CONFIG_NETFILTER_XT_MARK is not set + +# +# Xtables targets +# +# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set +# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set +# CONFIG_NETFILTER_XT_TARGET_HMARK is not set +# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set +# CONFIG_NETFILTER_XT_TARGET_LED is not set +# CONFIG_NETFILTER_XT_TARGET_LOG is not set +# CONFIG_NETFILTER_XT_TARGET_MARK is not set +# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set +# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set +# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set +# CONFIG_NETFILTER_XT_TARGET_TEE is not set +# CONFIG_NETFILTER_XT_TARGET_SECMARK is not set +# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set + +# +# Xtables matches +# +# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set +# CONFIG_NETFILTER_XT_MATCH_BPF is not set +# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set +# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set +# CONFIG_NETFILTER_XT_MATCH_CPU is not set +# CONFIG_NETFILTER_XT_MATCH_DCCP is not set +# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set +# CONFIG_NETFILTER_XT_MATCH_DSCP is not set +# CONFIG_NETFILTER_XT_MATCH_ECN is not set +# CONFIG_NETFILTER_XT_MATCH_ESP is not set +# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_HL is not set +# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set +# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set +# CONFIG_NETFILTER_XT_MATCH_L2TP is not set +# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set +# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_MAC is not set +# CONFIG_NETFILTER_XT_MATCH_MARK is not set +# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set +# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set +# CONFIG_NETFILTER_XT_MATCH_OWNER is not set +# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set +# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set +# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set +# CONFIG_NETFILTER_XT_MATCH_REALM is not set +# CONFIG_NETFILTER_XT_MATCH_RECENT is not set +# CONFIG_NETFILTER_XT_MATCH_SCTP is not set +# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set +# CONFIG_NETFILTER_XT_MATCH_STRING is not set +# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set +# CONFIG_NETFILTER_XT_MATCH_TIME is not set +# CONFIG_NETFILTER_XT_MATCH_U32 is not set +# CONFIG_IP_SET is not set +# CONFIG_IP_VS is not set + +# +# IP: Netfilter Configuration +# +# CONFIG_NF_DEFRAG_IPV4 is not set +# CONFIG_NF_SOCKET_IPV4 is not set +# CONFIG_NF_DUP_IPV4 is not set +# CONFIG_NF_LOG_ARP is not set +# CONFIG_NF_LOG_IPV4 is not set +# CONFIG_NF_REJECT_IPV4 is not set +CONFIG_IP_NF_IPTABLES=m +# CONFIG_IP_NF_MATCH_AH is not set +# CONFIG_IP_NF_MATCH_ECN is not set +# CONFIG_IP_NF_MATCH_TTL is not set +# CONFIG_IP_NF_FILTER is not set +# CONFIG_IP_NF_MANGLE is not set +# CONFIG_IP_NF_RAW is not set +# CONFIG_IP_NF_SECURITY is not set +# CONFIG_IP_NF_ARPTABLES is not set + +# +# IPv6: Netfilter Configuration +# +# CONFIG_NF_DEFRAG_IPV6 is not set +# CONFIG_NF_SOCKET_IPV6 is not set +# CONFIG_NF_DUP_IPV6 is not set +# CONFIG_NF_REJECT_IPV6 is not set +# CONFIG_NF_LOG_IPV6 is not set +# CONFIG_IP6_NF_IPTABLES is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_RDS is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_L2TP is not set +# CONFIG_BRIDGE is not set +CONFIG_HAVE_NET_DSA=y +# CONFIG_NET_DSA is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_PHONET is not set +# CONFIG_6LOWPAN is not set +# CONFIG_IEEE802154 is not set +CONFIG_NET_SCHED=y + +# +# Queueing/Scheduling +# +# CONFIG_NET_SCH_CBQ is not set +# CONFIG_NET_SCH_HTB is not set +# CONFIG_NET_SCH_HFSC is not set +# CONFIG_NET_SCH_PRIO is not set +# CONFIG_NET_SCH_MULTIQ is not set +# CONFIG_NET_SCH_RED is not set +# CONFIG_NET_SCH_SFB is not set +# CONFIG_NET_SCH_SFQ is not set +# CONFIG_NET_SCH_TEQL is not set +# CONFIG_NET_SCH_TBF is not set +# CONFIG_NET_SCH_GRED is not set +# CONFIG_NET_SCH_DSMARK is not set +# CONFIG_NET_SCH_NETEM is not set +# CONFIG_NET_SCH_DRR is not set +# CONFIG_NET_SCH_MQPRIO is not set +# CONFIG_NET_SCH_CHOKE is not set +# CONFIG_NET_SCH_QFQ is not set +# CONFIG_NET_SCH_CODEL is not set +# CONFIG_NET_SCH_FQ_CODEL is not set +# CONFIG_NET_SCH_FQ is not set +# CONFIG_NET_SCH_HHF is not set +# CONFIG_NET_SCH_PIE is not set +# CONFIG_NET_SCH_INGRESS is not set +# CONFIG_NET_SCH_PLUG is not set + +# +# Classification +# +CONFIG_NET_CLS=y +# CONFIG_NET_CLS_BASIC is not set +# CONFIG_NET_CLS_TCINDEX is not set +# CONFIG_NET_CLS_ROUTE4 is not set +# CONFIG_NET_CLS_FW is not set +# CONFIG_NET_CLS_U32 is not set +# CONFIG_NET_CLS_RSVP is not set +# CONFIG_NET_CLS_RSVP6 is not set +# CONFIG_NET_CLS_FLOW is not set +# CONFIG_NET_CLS_CGROUP is not set +# CONFIG_NET_CLS_BPF is not set +# CONFIG_NET_CLS_FLOWER is not set +# CONFIG_NET_CLS_MATCHALL is not set +CONFIG_NET_EMATCH=y +CONFIG_NET_EMATCH_STACK=32 +# CONFIG_NET_EMATCH_CMP is not set +# CONFIG_NET_EMATCH_NBYTE is not set +# CONFIG_NET_EMATCH_U32 is not set +# CONFIG_NET_EMATCH_META is not set +# CONFIG_NET_EMATCH_TEXT is not set +CONFIG_NET_CLS_ACT=y +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_SAMPLE is not set +# CONFIG_NET_ACT_IPT is not set +# CONFIG_NET_ACT_NAT is not set +# CONFIG_NET_ACT_PEDIT is not set +# CONFIG_NET_ACT_SIMP is not set +# CONFIG_NET_ACT_SKBEDIT is not set +# CONFIG_NET_ACT_CSUM is not set +# CONFIG_NET_ACT_VLAN is not set +# CONFIG_NET_ACT_BPF is not set +# CONFIG_NET_ACT_SKBMOD is not set +# CONFIG_NET_ACT_IFE is not set +# CONFIG_NET_ACT_TUNNEL_KEY is not set +CONFIG_NET_SCH_FIFO=y +CONFIG_DCB=y +CONFIG_DNS_RESOLVER=y +# CONFIG_BATMAN_ADV is not set +# CONFIG_OPENVSWITCH is not set +# CONFIG_VSOCKETS is not set +# CONFIG_NETLINK_DIAG is not set +CONFIG_MPLS=y +# CONFIG_NET_MPLS_GSO is not set +# CONFIG_MPLS_ROUTING is not set +# CONFIG_HSR is not set +CONFIG_NET_SWITCHDEV=y +CONFIG_NET_L3_MASTER_DEV=y +CONFIG_NET_NCSI=y +CONFIG_RPS=y +CONFIG_RFS_ACCEL=y +CONFIG_XPS=y +CONFIG_CGROUP_NET_PRIO=y +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_NET_RX_BUSY_POLL=y +CONFIG_BQL=y +CONFIG_BPF_JIT=y +CONFIG_NET_FLOW_LIMIT=y + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NET_TCPPROBE is not set +# CONFIG_NET_DROP_MONITOR is not set +CONFIG_HAMRADIO=y + +# +# Packet Radio protocols +# +# CONFIG_AX25 is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_AF_KCM is not set +# CONFIG_STREAM_PARSER is not set +CONFIG_FIB_RULES=y +CONFIG_WIRELESS=y +# CONFIG_CFG80211 is not set +# CONFIG_LIB80211 is not set + +# +# CFG80211 needs to be enabled for MAC80211 +# +CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 +# CONFIG_WIMAX is not set +CONFIG_RFKILL=y +CONFIG_RFKILL_LEDS=y +CONFIG_RFKILL_INPUT=y +# CONFIG_RFKILL_GPIO is not set +# CONFIG_NET_9P is not set +# CONFIG_CAIF is not set +# CONFIG_CEPH_LIB is not set +# CONFIG_NFC is not set +# CONFIG_PSAMPLE is not set +# CONFIG_NET_IFE is not set +CONFIG_LWTUNNEL=y +CONFIG_LWTUNNEL_BPF=y +# CONFIG_DST_CACHE is not set +# CONFIG_GRO_CELLS is not set +# CONFIG_NET_DEVLINK is not set +CONFIG_MAY_USE_DEVLINK=y +CONFIG_HAVE_EBPF_JIT=y + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER=y +CONFIG_UEVENT_HELPER_PATH="" +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_STANDALONE is not set +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_FW_LOADER_USER_HELPER_FALLBACK is not set +CONFIG_ALLOW_DEV_COREDUMP=y +# CONFIG_DEBUG_DRIVER is not set +# CONFIG_DEBUG_DEVRES is not set +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set +# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set +CONFIG_SYS_HYPERVISOR=y +# CONFIG_GENERIC_CPU_DEVICES is not set +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_SPI=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGMAP_IRQ=y +CONFIG_DMA_SHARED_BUFFER=y +# CONFIG_DMA_FENCE_TRACE is not set +# CONFIG_DMA_CMA is not set + +# +# Bus devices +# +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +# CONFIG_MTD is not set +# CONFIG_OF is not set +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_PARPORT=m +CONFIG_PARPORT_PC=m +# CONFIG_PARPORT_SERIAL is not set +CONFIG_PARPORT_PC_FIFO=y +# CONFIG_PARPORT_PC_SUPERIO is not set +# CONFIG_PARPORT_GSC is not set +# CONFIG_PARPORT_AX88796 is not set +CONFIG_PARPORT_1284=y +CONFIG_PNP=y +# CONFIG_PNP_DEBUG_MESSAGES is not set + +# +# Protocols +# +CONFIG_PNPACPI=y +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_NULL_BLK is not set +# CONFIG_BLK_DEV_FD is not set +# CONFIG_PARIDE is not set +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set +# CONFIG_ZRAM is not set +# CONFIG_BLK_CPQ_CISS_DA is not set +# CONFIG_BLK_DEV_DAC960 is not set +# CONFIG_BLK_DEV_UMEM is not set +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +# CONFIG_BLK_DEV_DRBD is not set +# CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_SKD is not set +# CONFIG_BLK_DEV_SX8 is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=65536 +CONFIG_BLK_DEV_RAM_DAX=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_XEN_BLKDEV_FRONTEND=y +# CONFIG_XEN_BLKDEV_BACKEND is not set +CONFIG_VIRTIO_BLK=y +# CONFIG_VIRTIO_BLK_SCSI is not set +# CONFIG_BLK_DEV_HD is not set +# CONFIG_BLK_DEV_RBD is not set +# CONFIG_BLK_DEV_RSXX is not set +# CONFIG_BLK_DEV_NVME is not set +# CONFIG_NVME_FC is not set + +# +# Misc devices +# +# CONFIG_SENSORS_LIS3LV02D is not set +# CONFIG_AD525X_DPOT is not set +# CONFIG_DUMMY_IRQ is not set +# CONFIG_IBM_ASM is not set +# CONFIG_PHANTOM is not set +# CONFIG_SGI_IOC4 is not set +# CONFIG_TIFM_CORE is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_HP_ILO is not set +# CONFIG_APDS9802ALS is not set +# CONFIG_ISL29003 is not set +# CONFIG_ISL29020 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_SENSORS_BH1770 is not set +# CONFIG_SENSORS_APDS990X is not set +# CONFIG_HMC6352 is not set +# CONFIG_DS1682 is not set +# CONFIG_TI_DAC7512 is not set +CONFIG_VMWARE_BALLOON=m +# CONFIG_USB_SWITCH_FSA9480 is not set +# CONFIG_LATTICE_ECP3_CONFIG is not set +CONFIG_SRAM=y +# CONFIG_PANEL is not set +# CONFIG_C2PORT is not set + +# +# EEPROM support +# +# CONFIG_EEPROM_AT24 is not set +# CONFIG_EEPROM_AT25 is not set +# CONFIG_EEPROM_LEGACY is not set +# CONFIG_EEPROM_MAX6875 is not set +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_EEPROM_93XX46 is not set +# CONFIG_EEPROM_IDT_89HPESX is not set +# CONFIG_CB710_CORE is not set + +# +# Texas Instruments shared transport line discipline +# +# CONFIG_TI_ST is not set +# CONFIG_SENSORS_LIS3_I2C is not set + +# +# Altera FPGA firmware download module +# +# CONFIG_ALTERA_STAPL is not set +# CONFIG_INTEL_MEI is not set +# CONFIG_INTEL_MEI_ME is not set +# CONFIG_INTEL_MEI_TXE is not set +CONFIG_VMWARE_VMCI=m + +# +# Intel MIC Bus Driver +# +# CONFIG_INTEL_MIC_BUS is not set + +# +# SCIF Bus Driver +# +# CONFIG_SCIF_BUS is not set + +# +# VOP Bus Driver +# +# CONFIG_VOP_BUS is not set + +# +# Intel MIC Host Driver +# + +# +# Intel MIC Card Driver +# + +# +# SCIF Driver +# + +# +# Intel MIC Coprocessor State Management (COSM) Drivers +# + +# +# VOP Driver +# +# CONFIG_GENWQE is not set +# CONFIG_ECHO is not set +# CONFIG_CXL_BASE is not set +# CONFIG_CXL_AFU_DRIVER_OPS is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +CONFIG_SCSI_MOD=y +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_NETLINK=y +# CONFIG_SCSI_MQ_DEFAULT is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +CONFIG_BLK_DEV_SR=y +# CONFIG_BLK_DEV_SR_VENDOR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set +CONFIG_SCSI_CONSTANTS=y +CONFIG_SCSI_LOGGING=y +CONFIG_SCSI_SCAN_ASYNC=y + +# +# SCSI Transports +# +CONFIG_SCSI_SPI_ATTRS=m +CONFIG_SCSI_FC_ATTRS=m +# CONFIG_SCSI_ISCSI_ATTRS is not set +CONFIG_SCSI_SAS_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +CONFIG_SCSI_LOWLEVEL=y +# CONFIG_ISCSI_TCP is not set +# CONFIG_ISCSI_BOOT_SYSFS is not set +# CONFIG_SCSI_CXGB3_ISCSI is not set +# CONFIG_SCSI_CXGB4_ISCSI is not set +# CONFIG_SCSI_BNX2_ISCSI is not set +# CONFIG_BE2ISCSI is not set +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set +# CONFIG_SCSI_HPSA is not set +# CONFIG_SCSI_3W_9XXX is not set +# CONFIG_SCSI_3W_SAS is not set +# CONFIG_SCSI_ACARD is not set +# CONFIG_SCSI_AACRAID is not set +# CONFIG_SCSI_AIC7XXX is not set +# CONFIG_SCSI_AIC79XX is not set +# CONFIG_SCSI_AIC94XX is not set +# CONFIG_SCSI_MVSAS is not set +# CONFIG_SCSI_MVUMI is not set +# CONFIG_SCSI_DPT_I2O is not set +# CONFIG_SCSI_ADVANSYS is not set +# CONFIG_SCSI_ARCMSR is not set +# CONFIG_SCSI_ESAS2R is not set +CONFIG_MEGARAID_NEWGEN=y +# CONFIG_MEGARAID_MM is not set +# CONFIG_MEGARAID_LEGACY is not set +# CONFIG_MEGARAID_SAS is not set +# CONFIG_SCSI_MPT3SAS is not set +# CONFIG_SCSI_MPT2SAS is not set +# CONFIG_SCSI_SMARTPQI is not set +# CONFIG_SCSI_UFSHCD is not set +# CONFIG_SCSI_HPTIOP is not set +# CONFIG_SCSI_BUSLOGIC is not set +# CONFIG_VMWARE_PVSCSI is not set +# CONFIG_XEN_SCSI_FRONTEND is not set +# CONFIG_LIBFC is not set +# CONFIG_SCSI_SNIC is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_FUTURE_DOMAIN is not set +# CONFIG_SCSI_GDTH is not set +# CONFIG_SCSI_ISCI is not set +# CONFIG_SCSI_IPS is not set +# CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_INIA100 is not set +# CONFIG_SCSI_PPA is not set +# CONFIG_SCSI_IMM is not set +# CONFIG_SCSI_STEX is not set +# CONFIG_SCSI_SYM53C8XX_2 is not set +# CONFIG_SCSI_IPR is not set +# CONFIG_SCSI_QLOGIC_1280 is not set +# CONFIG_SCSI_QLA_FC is not set +# CONFIG_SCSI_QLA_ISCSI is not set +# CONFIG_SCSI_LPFC is not set +# CONFIG_SCSI_DC395x is not set +# CONFIG_SCSI_AM53C974 is not set +# CONFIG_SCSI_WD719X is not set +# CONFIG_SCSI_DEBUG is not set +# CONFIG_SCSI_PMCRAID is not set +# CONFIG_SCSI_PM8001 is not set +# CONFIG_SCSI_BFA_FC is not set +# CONFIG_SCSI_VIRTIO is not set +# CONFIG_SCSI_CHELSIO_FCOE is not set +CONFIG_SCSI_DH=y +# CONFIG_SCSI_DH_RDAC is not set +# CONFIG_SCSI_DH_HP_SW is not set +# CONFIG_SCSI_DH_EMC is not set +# CONFIG_SCSI_DH_ALUA is not set +# CONFIG_SCSI_OSD_INITIATOR is not set +CONFIG_ATA=y +# CONFIG_ATA_NONSTANDARD is not set +CONFIG_ATA_VERBOSE_ERROR=y +CONFIG_ATA_ACPI=y +CONFIG_SATA_ZPODD=y +CONFIG_SATA_PMP=y + +# +# Controllers with non-SFF native interface +# +CONFIG_SATA_AHCI=m +CONFIG_SATA_AHCI_PLATFORM=m +# CONFIG_SATA_INIC162X is not set +CONFIG_SATA_ACARD_AHCI=m +# CONFIG_SATA_SIL24 is not set +CONFIG_ATA_SFF=y + +# +# SFF controllers with custom DMA interface +# +# CONFIG_PDC_ADMA is not set +# CONFIG_SATA_QSTOR is not set +# CONFIG_SATA_SX4 is not set +CONFIG_ATA_BMDMA=y + +# +# SATA SFF controllers with BMDMA +# +CONFIG_ATA_PIIX=y +# CONFIG_SATA_DWC is not set +# CONFIG_SATA_MV is not set +# CONFIG_SATA_NV is not set +# CONFIG_SATA_PROMISE is not set +# CONFIG_SATA_SIL is not set +# CONFIG_SATA_SIS is not set +# CONFIG_SATA_SVW is not set +# CONFIG_SATA_ULI is not set +# CONFIG_SATA_VIA is not set +# CONFIG_SATA_VITESSE is not set + +# +# PATA SFF controllers with BMDMA +# +# CONFIG_PATA_ALI is not set +# CONFIG_PATA_AMD is not set +# CONFIG_PATA_ARTOP is not set +# CONFIG_PATA_ATIIXP is not set +# CONFIG_PATA_ATP867X is not set +# CONFIG_PATA_CMD64X is not set +# CONFIG_PATA_CYPRESS is not set +# CONFIG_PATA_EFAR is not set +# CONFIG_PATA_HPT366 is not set +# CONFIG_PATA_HPT37X is not set +# CONFIG_PATA_HPT3X2N is not set +# CONFIG_PATA_HPT3X3 is not set +# CONFIG_PATA_IT8213 is not set +# CONFIG_PATA_IT821X is not set +# CONFIG_PATA_JMICRON is not set +# CONFIG_PATA_MARVELL is not set +# CONFIG_PATA_NETCELL is not set +# CONFIG_PATA_NINJA32 is not set +# CONFIG_PATA_NS87415 is not set +# CONFIG_PATA_OLDPIIX is not set +# CONFIG_PATA_OPTIDMA is not set +# CONFIG_PATA_PDC2027X is not set +# CONFIG_PATA_PDC_OLD is not set +# CONFIG_PATA_RADISYS is not set +# CONFIG_PATA_RDC is not set +# CONFIG_PATA_SCH is not set +# CONFIG_PATA_SERVERWORKS is not set +# CONFIG_PATA_SIL680 is not set +CONFIG_PATA_SIS=y +# CONFIG_PATA_TOSHIBA is not set +# CONFIG_PATA_TRIFLEX is not set +# CONFIG_PATA_VIA is not set +# CONFIG_PATA_WINBOND is not set + +# +# PIO-only SFF controllers +# +# CONFIG_PATA_CMD640_PCI is not set +# CONFIG_PATA_MPIIX is not set +# CONFIG_PATA_NS87410 is not set +# CONFIG_PATA_OPTI is not set +# CONFIG_PATA_PLATFORM is not set +# CONFIG_PATA_RZ1000 is not set + +# +# Generic fallback / legacy drivers +# +CONFIG_PATA_ACPI=m +CONFIG_ATA_GENERIC=y +# CONFIG_PATA_LEGACY is not set +CONFIG_MD=y +CONFIG_BLK_DEV_MD=y +CONFIG_MD_AUTODETECT=y +# CONFIG_MD_LINEAR is not set +# CONFIG_MD_RAID0 is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID10 is not set +# CONFIG_MD_RAID456 is not set +# CONFIG_MD_MULTIPATH is not set +# CONFIG_MD_FAULTY is not set +# CONFIG_BCACHE is not set +CONFIG_BLK_DEV_DM_BUILTIN=y +CONFIG_BLK_DEV_DM=y +# CONFIG_DM_MQ_DEFAULT is not set +# CONFIG_DM_DEBUG is not set +# CONFIG_DM_CRYPT is not set +# CONFIG_DM_SNAPSHOT is not set +# CONFIG_DM_THIN_PROVISIONING is not set +# CONFIG_DM_CACHE is not set +# CONFIG_DM_ERA is not set +# CONFIG_DM_MIRROR is not set +# CONFIG_DM_RAID is not set +# CONFIG_DM_ZERO is not set +# CONFIG_DM_MULTIPATH is not set +# CONFIG_DM_DELAY is not set +CONFIG_DM_UEVENT=y +# CONFIG_DM_FLAKEY is not set +# CONFIG_DM_VERITY is not set +# CONFIG_DM_SWITCH is not set +# CONFIG_DM_LOG_WRITES is not set +# CONFIG_TARGET_CORE is not set +CONFIG_FUSION=y +CONFIG_FUSION_SPI=m +CONFIG_FUSION_FC=m +CONFIG_FUSION_SAS=m +CONFIG_FUSION_MAX_SGE=128 +# CONFIG_FUSION_CTL is not set +# CONFIG_FUSION_LAN is not set +CONFIG_FUSION_LOGGING=y + +# +# IEEE 1394 (FireWire) support +# +# CONFIG_FIREWIRE is not set +# CONFIG_FIREWIRE_NOSY is not set +CONFIG_MACINTOSH_DRIVERS=y +CONFIG_MAC_EMUMOUSEBTN=m +CONFIG_NETDEVICES=y +CONFIG_NET_CORE=y +# CONFIG_BONDING is not set +# CONFIG_DUMMY is not set +# CONFIG_EQUALIZER is not set +CONFIG_NET_FC=y +# CONFIG_IFB is not set +# CONFIG_NET_TEAM is not set +# CONFIG_MACVLAN is not set +# CONFIG_IPVLAN is not set +# CONFIG_VXLAN is not set +# CONFIG_MACSEC is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_RIONET is not set +CONFIG_TUN=y +# CONFIG_TUN_VNET_CROSS_LE is not set +# CONFIG_VETH is not set +CONFIG_VIRTIO_NET=y +# CONFIG_NLMON is not set +# CONFIG_NET_VRF is not set +# CONFIG_ARCNET is not set + +# +# CAIF transport drivers +# + +# +# Distributed Switch Architecture drivers +# +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_3COM=y +# CONFIG_VORTEX is not set +# CONFIG_TYPHOON is not set +CONFIG_NET_VENDOR_ADAPTEC=y +# CONFIG_ADAPTEC_STARFIRE is not set +CONFIG_NET_VENDOR_AGERE=y +# CONFIG_ET131X is not set +CONFIG_NET_VENDOR_ALACRITECH=y +# CONFIG_SLICOSS is not set +CONFIG_NET_VENDOR_ALTEON=y +# CONFIG_ACENIC is not set +# CONFIG_ALTERA_TSE is not set +CONFIG_NET_VENDOR_AMAZON=y +# CONFIG_ENA_ETHERNET is not set +CONFIG_NET_VENDOR_AMD=y +# CONFIG_AMD8111_ETH is not set +# CONFIG_PCNET32 is not set +# CONFIG_AMD_XGBE is not set +# CONFIG_AMD_XGBE_HAVE_ECC is not set +CONFIG_NET_VENDOR_AQUANTIA=y +# CONFIG_AQTION is not set +CONFIG_NET_VENDOR_ARC=y +CONFIG_NET_VENDOR_ATHEROS=y +# CONFIG_ATL2 is not set +# CONFIG_ATL1 is not set +# CONFIG_ATL1E is not set +# CONFIG_ATL1C is not set +# CONFIG_ALX is not set +CONFIG_NET_VENDOR_AURORA=y +# CONFIG_AURORA_NB8800 is not set +CONFIG_NET_CADENCE=y +# CONFIG_MACB is not set +CONFIG_NET_VENDOR_BROADCOM=y +# CONFIG_B44 is not set +# CONFIG_BCMGENET is not set +# CONFIG_BNX2 is not set +# CONFIG_CNIC is not set +# CONFIG_TIGON3 is not set +# CONFIG_BNX2X is not set +# CONFIG_BNXT is not set +CONFIG_NET_VENDOR_BROCADE=y +# CONFIG_BNA is not set +CONFIG_NET_VENDOR_CAVIUM=y +# CONFIG_THUNDER_NIC_PF is not set +# CONFIG_THUNDER_NIC_VF is not set +# CONFIG_THUNDER_NIC_BGX is not set +# CONFIG_THUNDER_NIC_RGX is not set +# CONFIG_LIQUIDIO is not set +# CONFIG_LIQUIDIO_VF is not set +CONFIG_NET_VENDOR_CHELSIO=y +# CONFIG_CHELSIO_T1 is not set +# CONFIG_CHELSIO_T3 is not set +# CONFIG_CHELSIO_T4 is not set +# CONFIG_CHELSIO_T4VF is not set +CONFIG_NET_VENDOR_CISCO=y +# CONFIG_ENIC is not set +# CONFIG_CX_ECAT is not set +# CONFIG_DNET is not set +CONFIG_NET_VENDOR_DEC=y +CONFIG_NET_TULIP=y +# CONFIG_DE2104X is not set +# CONFIG_TULIP is not set +# CONFIG_DE4X5 is not set +# CONFIG_WINBOND_840 is not set +# CONFIG_DM9102 is not set +# CONFIG_ULI526X is not set +CONFIG_NET_VENDOR_DLINK=y +# CONFIG_DL2K is not set +# CONFIG_SUNDANCE is not set +CONFIG_NET_VENDOR_EMULEX=y +# CONFIG_BE2NET is not set +CONFIG_NET_VENDOR_EZCHIP=y +CONFIG_NET_VENDOR_EXAR=y +# CONFIG_S2IO is not set +# CONFIG_VXGE is not set +CONFIG_NET_VENDOR_HP=y +# CONFIG_HP100 is not set +CONFIG_NET_VENDOR_INTEL=y +# CONFIG_E100 is not set +CONFIG_E1000=m +# CONFIG_E1000E is not set +# CONFIG_IGB is not set +# CONFIG_IGBVF is not set +# CONFIG_IXGB is not set +# CONFIG_IXGBE is not set +# CONFIG_IXGBEVF is not set +# CONFIG_I40E is not set +# CONFIG_I40EVF is not set +# CONFIG_FM10K is not set +CONFIG_NET_VENDOR_I825XX=y +# CONFIG_JME is not set +CONFIG_NET_VENDOR_MARVELL=y +# CONFIG_MVMDIO is not set +# CONFIG_SKGE is not set +# CONFIG_SKY2 is not set +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MLX4_EN is not set +# CONFIG_MLX4_CORE is not set +# CONFIG_MLX5_CORE is not set +# CONFIG_MLXSW_CORE is not set +CONFIG_NET_VENDOR_MICREL=y +# CONFIG_KS8842 is not set +# CONFIG_KS8851 is not set +# CONFIG_KS8851_MLL is not set +# CONFIG_KSZ884X_PCI is not set +CONFIG_NET_VENDOR_MICROCHIP=y +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set +CONFIG_NET_VENDOR_MYRI=y +# CONFIG_MYRI10GE is not set +# CONFIG_FEALNX is not set +CONFIG_NET_VENDOR_NATSEMI=y +# CONFIG_NATSEMI is not set +# CONFIG_NS83820 is not set +CONFIG_NET_VENDOR_NETRONOME=y +# CONFIG_NFP is not set +CONFIG_NET_VENDOR_8390=y +# CONFIG_NE2K_PCI is not set +CONFIG_NET_VENDOR_NVIDIA=y +# CONFIG_FORCEDETH is not set +CONFIG_NET_VENDOR_OKI=y +# CONFIG_ETHOC is not set +CONFIG_NET_PACKET_ENGINE=y +# CONFIG_HAMACHI is not set +# CONFIG_YELLOWFIN is not set +CONFIG_NET_VENDOR_QLOGIC=y +# CONFIG_QLA3XXX is not set +# CONFIG_QLCNIC is not set +# CONFIG_QLGE is not set +# CONFIG_NETXEN_NIC is not set +# CONFIG_QED is not set +CONFIG_NET_VENDOR_QUALCOMM=y +# CONFIG_QCOM_EMAC is not set +CONFIG_NET_VENDOR_REALTEK=y +# CONFIG_ATP is not set +# CONFIG_8139CP is not set +# CONFIG_8139TOO is not set +# CONFIG_R8169 is not set +CONFIG_NET_VENDOR_RENESAS=y +CONFIG_NET_VENDOR_RDC=y +# CONFIG_R6040 is not set +CONFIG_NET_VENDOR_ROCKER=y +CONFIG_NET_VENDOR_SAMSUNG=y +# CONFIG_SXGBE_ETH is not set +CONFIG_NET_VENDOR_SEEQ=y +CONFIG_NET_VENDOR_SILAN=y +# CONFIG_SC92031 is not set +CONFIG_NET_VENDOR_SIS=y +# CONFIG_SIS900 is not set +# CONFIG_SIS190 is not set +CONFIG_NET_VENDOR_SOLARFLARE=y +# CONFIG_SFC is not set +# CONFIG_SFC_FALCON is not set +CONFIG_NET_VENDOR_SMSC=y +# CONFIG_EPIC100 is not set +# CONFIG_SMSC911X is not set +# CONFIG_SMSC9420 is not set +CONFIG_NET_VENDOR_STMICRO=y +# CONFIG_STMMAC_ETH is not set +CONFIG_NET_VENDOR_SUN=y +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNGEM is not set +# CONFIG_CASSINI is not set +# CONFIG_NIU is not set +CONFIG_NET_VENDOR_TEHUTI=y +# CONFIG_TEHUTI is not set +CONFIG_NET_VENDOR_TI=y +# CONFIG_TI_CPSW_ALE is not set +# CONFIG_TLAN is not set +CONFIG_NET_VENDOR_VIA=y +# CONFIG_VIA_RHINE is not set +# CONFIG_VIA_VELOCITY is not set +CONFIG_NET_VENDOR_WIZNET=y +# CONFIG_WIZNET_W5100 is not set +# CONFIG_WIZNET_W5300 is not set +CONFIG_FDDI=y +# CONFIG_DEFXX is not set +# CONFIG_SKFP is not set +# CONFIG_HIPPI is not set +# CONFIG_NET_SB1000 is not set +CONFIG_PHYLIB=y +CONFIG_SWPHY=y +# CONFIG_LED_TRIGGER_PHY is not set + +# +# MDIO bus device drivers +# +# CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_MDIO_BITBANG is not set +# CONFIG_MDIO_OCTEON is not set +# CONFIG_MDIO_THUNDER is not set + +# +# MII PHY device drivers +# +# CONFIG_AMD_PHY is not set +# CONFIG_AQUANTIA_PHY is not set +# CONFIG_AT803X_PHY is not set +# CONFIG_BCM7XXX_PHY is not set +# CONFIG_BCM87XX_PHY is not set +# CONFIG_BROADCOM_PHY is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_DAVICOM_PHY is not set +# CONFIG_DP83848_PHY is not set +# CONFIG_DP83867_PHY is not set +CONFIG_FIXED_PHY=y +# CONFIG_ICPLUS_PHY is not set +# CONFIG_INTEL_XWAY_PHY is not set +# CONFIG_LSI_ET1011C_PHY is not set +# CONFIG_LXT_PHY is not set +# CONFIG_MARVELL_PHY is not set +# CONFIG_MICREL_PHY is not set +# CONFIG_MICROCHIP_PHY is not set +# CONFIG_MICROSEMI_PHY is not set +# CONFIG_NATIONAL_PHY is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_REALTEK_PHY is not set +# CONFIG_SMSC_PHY is not set +# CONFIG_STE10XP is not set +# CONFIG_TERANETICS_PHY is not set +# CONFIG_VITESSE_PHY is not set +# CONFIG_XILINX_GMII2RGMII is not set +# CONFIG_MICREL_KS8995MA is not set +# CONFIG_PLIP is not set +CONFIG_PPP=y +# CONFIG_PPP_BSDCOMP is not set +# CONFIG_PPP_DEFLATE is not set +CONFIG_PPP_FILTER=y +# CONFIG_PPP_MPPE is not set +CONFIG_PPP_MULTILINK=y +# CONFIG_PPPOE is not set +# CONFIG_PPP_ASYNC is not set +# CONFIG_PPP_SYNC_TTY is not set +# CONFIG_SLIP is not set +CONFIG_SLHC=y +# CONFIG_USB_NET_DRIVERS is not set +CONFIG_WLAN=y +# CONFIG_WIRELESS_WDS is not set +CONFIG_WLAN_VENDOR_ADMTEK=y +CONFIG_WLAN_VENDOR_ATH=y +# CONFIG_ATH_DEBUG is not set +CONFIG_ATH5K_PCI=y +CONFIG_WLAN_VENDOR_ATMEL=y +CONFIG_WLAN_VENDOR_BROADCOM=y +CONFIG_WLAN_VENDOR_CISCO=y +CONFIG_WLAN_VENDOR_INTEL=y +CONFIG_WLAN_VENDOR_INTERSIL=y +# CONFIG_HOSTAP is not set +# CONFIG_PRISM54 is not set +CONFIG_WLAN_VENDOR_MARVELL=y +CONFIG_WLAN_VENDOR_MEDIATEK=y +CONFIG_WLAN_VENDOR_RALINK=y +CONFIG_WLAN_VENDOR_REALTEK=y +CONFIG_WLAN_VENDOR_RSI=y +CONFIG_WLAN_VENDOR_ST=y +# CONFIG_WLAN_VENDOR_TI is not set +CONFIG_WLAN_VENDOR_ZYDAS=y + +# +# Enable WiMAX (Networking options) to see the WiMAX drivers +# +CONFIG_WAN=y +# CONFIG_HDLC is not set +# CONFIG_DLCI is not set +# CONFIG_SBNI is not set +CONFIG_XEN_NETDEV_FRONTEND=y +# CONFIG_XEN_NETDEV_BACKEND is not set +# CONFIG_VMXNET3 is not set +CONFIG_FUJITSU_ES=m +CONFIG_ISDN=y +# CONFIG_ISDN_I4L is not set +# CONFIG_ISDN_CAPI is not set +# CONFIG_ISDN_DRV_GIGASET is not set +# CONFIG_HYSDN is not set +# CONFIG_MISDN is not set +CONFIG_NVM=y +# CONFIG_NVM_DEBUG is not set +# CONFIG_NVM_RRPC is not set + +# +# Input device support +# +CONFIG_INPUT=y +CONFIG_INPUT_LEDS=m +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set +# CONFIG_INPUT_SPARSEKMAP is not set +# CONFIG_INPUT_MATRIXKMAP is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +CONFIG_INPUT_JOYDEV=m +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +# CONFIG_KEYBOARD_ADP5520 is not set +# CONFIG_KEYBOARD_ADP5588 is not set +# CONFIG_KEYBOARD_ADP5589 is not set +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_QT1070 is not set +# CONFIG_KEYBOARD_QT2160 is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_GPIO is not set +# CONFIG_KEYBOARD_GPIO_POLLED is not set +# CONFIG_KEYBOARD_TCA6416 is not set +# CONFIG_KEYBOARD_TCA8418 is not set +# CONFIG_KEYBOARD_MATRIX is not set +# CONFIG_KEYBOARD_LM8323 is not set +# CONFIG_KEYBOARD_LM8333 is not set +# CONFIG_KEYBOARD_MAX7359 is not set +# CONFIG_KEYBOARD_MCS is not set +# CONFIG_KEYBOARD_MPR121 is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_OPENCORES is not set +# CONFIG_KEYBOARD_SAMSUNG is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set +# CONFIG_KEYBOARD_TWL4030 is not set +# CONFIG_KEYBOARD_XTKBD is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=m +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_BYD=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_CYPRESS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +CONFIG_MOUSE_PS2_ELANTECH=y +CONFIG_MOUSE_PS2_SENTELIC=y +CONFIG_MOUSE_PS2_TOUCHKIT=y +CONFIG_MOUSE_PS2_FOCALTECH=y +CONFIG_MOUSE_PS2_VMMOUSE=y +# CONFIG_MOUSE_SERIAL is not set +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_CYAPA is not set +# CONFIG_MOUSE_ELAN_I2C is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_MOUSE_SYNAPTICS_I2C is not set +# CONFIG_MOUSE_SYNAPTICS_USB is not set +CONFIG_INPUT_JOYSTICK=y +# CONFIG_JOYSTICK_ANALOG is not set +# CONFIG_JOYSTICK_A3D is not set +# CONFIG_JOYSTICK_ADI is not set +# CONFIG_JOYSTICK_COBRA is not set +# CONFIG_JOYSTICK_GF2K is not set +# CONFIG_JOYSTICK_GRIP is not set +# CONFIG_JOYSTICK_GRIP_MP is not set +# CONFIG_JOYSTICK_GUILLEMOT is not set +# CONFIG_JOYSTICK_INTERACT is not set +# CONFIG_JOYSTICK_SIDEWINDER is not set +# CONFIG_JOYSTICK_TMDC is not set +# CONFIG_JOYSTICK_IFORCE is not set +# CONFIG_JOYSTICK_WARRIOR is not set +# CONFIG_JOYSTICK_MAGELLAN is not set +# CONFIG_JOYSTICK_SPACEORB is not set +# CONFIG_JOYSTICK_SPACEBALL is not set +# CONFIG_JOYSTICK_STINGER is not set +# CONFIG_JOYSTICK_TWIDJOY is not set +# CONFIG_JOYSTICK_ZHENHUA is not set +# CONFIG_JOYSTICK_DB9 is not set +# CONFIG_JOYSTICK_GAMECON is not set +# CONFIG_JOYSTICK_TURBOGRAFX is not set +# CONFIG_JOYSTICK_AS5011 is not set +# CONFIG_JOYSTICK_JOYDUMP is not set +# CONFIG_JOYSTICK_XPAD is not set +# CONFIG_JOYSTICK_WALKERA0701 is not set +CONFIG_INPUT_TABLET=y +# CONFIG_TABLET_USB_ACECAD is not set +# CONFIG_TABLET_USB_AIPTEK is not set +# CONFIG_TABLET_USB_GTCO is not set +# CONFIG_TABLET_USB_HANWANG is not set +# CONFIG_TABLET_USB_KBTAB is not set +# CONFIG_TABLET_USB_PEGASUS is not set +# CONFIG_TABLET_SERIAL_WACOM4 is not set +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_PROPERTIES=y +# CONFIG_TOUCHSCREEN_88PM860X is not set +# CONFIG_TOUCHSCREEN_ADS7846 is not set +# CONFIG_TOUCHSCREEN_AD7877 is not set +# CONFIG_TOUCHSCREEN_AD7879 is not set +# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set +# CONFIG_TOUCHSCREEN_AUO_PIXCIR is not set +# CONFIG_TOUCHSCREEN_BU21013 is not set +# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set +# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set +# CONFIG_TOUCHSCREEN_CYTTSP4_CORE is not set +# CONFIG_TOUCHSCREEN_DA9034 is not set +# CONFIG_TOUCHSCREEN_DA9052 is not set +# CONFIG_TOUCHSCREEN_DYNAPRO is not set +# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set +# CONFIG_TOUCHSCREEN_EETI is not set +# CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set +# CONFIG_TOUCHSCREEN_FUJITSU is not set +# CONFIG_TOUCHSCREEN_GOODIX is not set +# CONFIG_TOUCHSCREEN_ILI210X is not set +# CONFIG_TOUCHSCREEN_GUNZE is not set +# CONFIG_TOUCHSCREEN_EKTF2127 is not set +# CONFIG_TOUCHSCREEN_ELAN is not set +# CONFIG_TOUCHSCREEN_ELO is not set +# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set +# CONFIG_TOUCHSCREEN_WACOM_I2C is not set +# CONFIG_TOUCHSCREEN_MAX11801 is not set +# CONFIG_TOUCHSCREEN_MCS5000 is not set +# CONFIG_TOUCHSCREEN_MMS114 is not set +# CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set +# CONFIG_TOUCHSCREEN_MTOUCH is not set +# CONFIG_TOUCHSCREEN_INEXIO is not set +# CONFIG_TOUCHSCREEN_MK712 is not set +# CONFIG_TOUCHSCREEN_PENMOUNT is not set +# CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set +# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set +# CONFIG_TOUCHSCREEN_TOUCHWIN is not set +# CONFIG_TOUCHSCREEN_PIXCIR is not set +# CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set +# CONFIG_TOUCHSCREEN_WM831X is not set +# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set +# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set +# CONFIG_TOUCHSCREEN_TSC_SERIO is not set +# CONFIG_TOUCHSCREEN_TSC2004 is not set +# CONFIG_TOUCHSCREEN_TSC2005 is not set +# CONFIG_TOUCHSCREEN_TSC2007 is not set +# CONFIG_TOUCHSCREEN_PCAP is not set +# CONFIG_TOUCHSCREEN_RM_TS is not set +# CONFIG_TOUCHSCREEN_SILEAD is not set +# CONFIG_TOUCHSCREEN_SIS_I2C is not set +# CONFIG_TOUCHSCREEN_ST1232 is not set +# CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set +# CONFIG_TOUCHSCREEN_SX8654 is not set +# CONFIG_TOUCHSCREEN_TPS6507X is not set +# CONFIG_TOUCHSCREEN_ZET6223 is not set +# CONFIG_TOUCHSCREEN_ZFORCE is not set +# CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set +CONFIG_INPUT_MISC=y +# CONFIG_INPUT_88PM860X_ONKEY is not set +# CONFIG_INPUT_AD714X is not set +# CONFIG_INPUT_BMA150 is not set +# CONFIG_INPUT_E3X0_BUTTON is not set +# CONFIG_INPUT_PCSPKR is not set +# CONFIG_INPUT_MAX77693_HAPTIC is not set +# CONFIG_INPUT_MAX8925_ONKEY is not set +# CONFIG_INPUT_MAX8997_HAPTIC is not set +# CONFIG_INPUT_MMA8450 is not set +# CONFIG_INPUT_APANEL is not set +# CONFIG_INPUT_GP2A is not set +# CONFIG_INPUT_GPIO_BEEPER is not set +# CONFIG_INPUT_GPIO_TILT_POLLED is not set +# CONFIG_INPUT_GPIO_DECODER is not set +# CONFIG_INPUT_ATLAS_BTNS is not set +# CONFIG_INPUT_ATI_REMOTE2 is not set +# CONFIG_INPUT_KEYSPAN_REMOTE is not set +# CONFIG_INPUT_KXTJ9 is not set +# CONFIG_INPUT_POWERMATE is not set +# CONFIG_INPUT_YEALINK is not set +# CONFIG_INPUT_CM109 is not set +# CONFIG_INPUT_REGULATOR_HAPTIC is not set +# CONFIG_INPUT_TWL4030_PWRBUTTON is not set +# CONFIG_INPUT_TWL4030_VIBRA is not set +# CONFIG_INPUT_TWL6040_VIBRA is not set +CONFIG_INPUT_UINPUT=y +# CONFIG_INPUT_PALMAS_PWRBUTTON is not set +# CONFIG_INPUT_PCF8574 is not set +# CONFIG_INPUT_PWM_BEEPER is not set +# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set +# CONFIG_INPUT_DA9052_ONKEY is not set +# CONFIG_INPUT_DA9055_ONKEY is not set +# CONFIG_INPUT_DA9063_ONKEY is not set +# CONFIG_INPUT_WM831X_ON is not set +# CONFIG_INPUT_PCAP is not set +# CONFIG_INPUT_ADXL34X is not set +# CONFIG_INPUT_IMS_PCU is not set +# CONFIG_INPUT_CMA3000 is not set +# CONFIG_INPUT_XEN_KBDDEV_FRONTEND is not set +# CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set +# CONFIG_INPUT_DRV260X_HAPTICS is not set +# CONFIG_INPUT_DRV2665_HAPTICS is not set +# CONFIG_INPUT_DRV2667_HAPTICS is not set +# CONFIG_RMI4_CORE is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y +CONFIG_SERIO_I8042=y +# CONFIG_SERIO_SERPORT is not set +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_PARKBD is not set +# CONFIG_SERIO_PCIPS2 is not set +CONFIG_SERIO_LIBPS2=y +CONFIG_SERIO_RAW=m +# CONFIG_SERIO_ALTERA_PS2 is not set +# CONFIG_SERIO_PS2MULT is not set +# CONFIG_SERIO_ARC_PS2 is not set +# CONFIG_USERIO is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_TTY=y +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_VT_CONSOLE_SLEEP=y +CONFIG_HW_CONSOLE=y +CONFIG_VT_HW_CONSOLE_BINDING=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=0 +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_ROCKETPORT is not set +# CONFIG_CYCLADES is not set +# CONFIG_MOXA_INTELLIO is not set +# CONFIG_MOXA_SMARTIO is not set +# CONFIG_SYNCLINK is not set +# CONFIG_SYNCLINKMP is not set +# CONFIG_SYNCLINK_GT is not set +# CONFIG_NOZOMI is not set +# CONFIG_ISI is not set +# CONFIG_N_HDLC is not set +# CONFIG_N_GSM is not set +# CONFIG_TRACE_SINK is not set +CONFIG_DEVMEM=y +# CONFIG_DEVKMEM is not set + +# +# Serial drivers +# +CONFIG_SERIAL_EARLYCON=y +CONFIG_SERIAL_8250=y +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set +CONFIG_SERIAL_8250_PNP=y +CONFIG_SERIAL_8250_FINTEK=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_DMA=y +CONFIG_SERIAL_8250_PCI=y +CONFIG_SERIAL_8250_EXAR=y +CONFIG_SERIAL_8250_NR_UARTS=48 +CONFIG_SERIAL_8250_RUNTIME_UARTS=32 +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +# CONFIG_SERIAL_8250_DETECT_IRQ is not set +CONFIG_SERIAL_8250_RSA=y +# CONFIG_SERIAL_8250_FSL is not set +# CONFIG_SERIAL_8250_DW is not set +CONFIG_SERIAL_8250_RT288X=y +CONFIG_SERIAL_8250_LPSS=y +# CONFIG_SERIAL_8250_MID is not set +# CONFIG_SERIAL_8250_MOXA is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_KGDB_NMI=y +# CONFIG_SERIAL_MAX3100 is not set +CONFIG_SERIAL_MAX310X=y +# CONFIG_SERIAL_UARTLITE is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_CONSOLE_POLL=y +# CONFIG_SERIAL_JSM is not set +CONFIG_SERIAL_SCCNXP=y +CONFIG_SERIAL_SCCNXP_CONSOLE=y +# CONFIG_SERIAL_SC16IS7XX is not set +# CONFIG_SERIAL_ALTERA_JTAGUART is not set +# CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_IFX6X60 is not set +# CONFIG_SERIAL_ARC is not set +# CONFIG_SERIAL_RP2 is not set +# CONFIG_SERIAL_FSL_LPUART is not set +# CONFIG_SERIAL_DEV_BUS is not set +CONFIG_TTY_PRINTK=y +# CONFIG_PRINTER is not set +CONFIG_PPDEV=m +CONFIG_HVC_DRIVER=y +CONFIG_HVC_IRQ=y +CONFIG_HVC_XEN=y +CONFIG_HVC_XEN_FRONTEND=y +CONFIG_VIRTIO_CONSOLE=y +# CONFIG_IPMI_HANDLER is not set +CONFIG_HW_RANDOM=y +# CONFIG_HW_RANDOM_TIMERIOMEM is not set +# CONFIG_HW_RANDOM_INTEL is not set +# CONFIG_HW_RANDOM_AMD is not set +# CONFIG_HW_RANDOM_VIA is not set +# CONFIG_HW_RANDOM_VIRTIO is not set +# CONFIG_HW_RANDOM_TPM is not set +# CONFIG_NVRAM is not set +# CONFIG_R3964 is not set +# CONFIG_APPLICOM is not set +# CONFIG_MWAVE is not set +# CONFIG_RAW_DRIVER is not set +CONFIG_HPET=y +CONFIG_HPET_MMAP=y +CONFIG_HPET_MMAP_DEFAULT=y +# CONFIG_HANGCHECK_TIMER is not set +CONFIG_TCG_TPM=y +CONFIG_TCG_TIS_CORE=y +CONFIG_TCG_TIS=y +# CONFIG_TCG_TIS_SPI is not set +# CONFIG_TCG_TIS_I2C_ATMEL is not set +# CONFIG_TCG_TIS_I2C_INFINEON is not set +# CONFIG_TCG_TIS_I2C_NUVOTON is not set +# CONFIG_TCG_NSC is not set +# CONFIG_TCG_ATMEL is not set +# CONFIG_TCG_INFINEON is not set +# CONFIG_TCG_XEN is not set +# CONFIG_TCG_CRB is not set +# CONFIG_TCG_VTPM_PROXY is not set +# CONFIG_TCG_TIS_ST33ZP24_I2C is not set +# CONFIG_TCG_TIS_ST33ZP24_SPI is not set +# CONFIG_TELCLOCK is not set +CONFIG_DEVPORT=y +# CONFIG_XILLYBUS is not set + +# +# I2C support +# +CONFIG_I2C=y +CONFIG_ACPI_I2C_OPREGION=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_CHARDEV=y +# CONFIG_I2C_MUX is not set +CONFIG_I2C_HELPER_AUTO=y +CONFIG_I2C_ALGOBIT=m + +# +# I2C Hardware Bus support +# + +# +# PC SMBus host controller drivers +# +# CONFIG_I2C_ALI1535 is not set +# CONFIG_I2C_ALI1563 is not set +# CONFIG_I2C_ALI15X3 is not set +# CONFIG_I2C_AMD756 is not set +# CONFIG_I2C_AMD8111 is not set +# CONFIG_I2C_I801 is not set +# CONFIG_I2C_ISCH is not set +# CONFIG_I2C_ISMT is not set +CONFIG_I2C_PIIX4=m +# CONFIG_I2C_NFORCE2 is not set +# CONFIG_I2C_SIS5595 is not set +# CONFIG_I2C_SIS630 is not set +# CONFIG_I2C_SIS96X is not set +# CONFIG_I2C_VIA is not set +# CONFIG_I2C_VIAPRO is not set + +# +# ACPI drivers +# +# CONFIG_I2C_SCMI is not set + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_CBUS_GPIO is not set +# CONFIG_I2C_DESIGNWARE_PLATFORM is not set +# CONFIG_I2C_DESIGNWARE_PCI is not set +# CONFIG_I2C_EMEV2 is not set +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_PXA_PCI is not set +# CONFIG_I2C_SIMTEC is not set +# CONFIG_I2C_XILINX is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_DIOLAN_U2C is not set +# CONFIG_I2C_PARPORT is not set +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_ROBOTFUZZ_OSIF is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_MLXCPLD is not set +# CONFIG_I2C_STUB is not set +CONFIG_I2C_SLAVE=y +# CONFIG_I2C_SLAVE_EEPROM is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +CONFIG_SPI=y +# CONFIG_SPI_DEBUG is not set +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +# CONFIG_SPI_ALTERA is not set +# CONFIG_SPI_AXI_SPI_ENGINE is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_SPI_BUTTERFLY is not set +# CONFIG_SPI_CADENCE is not set +# CONFIG_SPI_DESIGNWARE is not set +# CONFIG_SPI_GPIO is not set +# CONFIG_SPI_LM70_LLP is not set +# CONFIG_SPI_OC_TINY is not set +# CONFIG_SPI_PXA2XX is not set +# CONFIG_SPI_PXA2XX_PCI is not set +# CONFIG_SPI_ROCKCHIP is not set +# CONFIG_SPI_SC18IS602 is not set +# CONFIG_SPI_XCOMM is not set +# CONFIG_SPI_XILINX is not set +# CONFIG_SPI_ZYNQMP_GQSPI is not set + +# +# SPI Protocol Masters +# +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_LOOPBACK_TEST is not set +# CONFIG_SPI_TLE62X0 is not set +# CONFIG_SPMI is not set +# CONFIG_HSI is not set + +# +# PPS support +# +# CONFIG_PPS is not set + +# +# PPS generators support +# + +# +# PTP clock support +# +# CONFIG_PTP_1588_CLOCK is not set + +# +# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. +# +CONFIG_PINCTRL=y + +# +# Pin controllers +# +CONFIG_PINMUX=y +CONFIG_PINCONF=y +CONFIG_GENERIC_PINCONF=y +# CONFIG_DEBUG_PINCTRL is not set +CONFIG_PINCTRL_AMD=y +CONFIG_PINCTRL_SX150X=y +CONFIG_PINCTRL_BAYTRAIL=y +# CONFIG_PINCTRL_CHERRYVIEW is not set +# CONFIG_PINCTRL_BROXTON is not set +# CONFIG_PINCTRL_GEMINILAKE is not set +# CONFIG_PINCTRL_SUNRISEPOINT is not set +CONFIG_GPIOLIB=y +CONFIG_GPIO_ACPI=y +CONFIG_GPIOLIB_IRQCHIP=y +# CONFIG_DEBUG_GPIO is not set +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO drivers +# +# CONFIG_GPIO_AMDPT is not set +# CONFIG_GPIO_DWAPB is not set +# CONFIG_GPIO_EXAR is not set +# CONFIG_GPIO_GENERIC_PLATFORM is not set +# CONFIG_GPIO_ICH is not set +CONFIG_GPIO_LYNXPOINT=y +# CONFIG_GPIO_MOCKUP is not set +# CONFIG_GPIO_VX855 is not set + +# +# Port-mapped I/O GPIO drivers +# +# CONFIG_GPIO_104_DIO_48E is not set +# CONFIG_GPIO_104_IDIO_16 is not set +# CONFIG_GPIO_104_IDI_48 is not set +# CONFIG_GPIO_F7188X is not set +# CONFIG_GPIO_GPIO_MM is not set +# CONFIG_GPIO_IT87 is not set +# CONFIG_GPIO_SCH is not set +# CONFIG_GPIO_SCH311X is not set +# CONFIG_GPIO_WS16C48 is not set + +# +# I2C GPIO expanders +# +# CONFIG_GPIO_ADP5588 is not set +# CONFIG_GPIO_MAX7300 is not set +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set +CONFIG_GPIO_SX150X=y +# CONFIG_GPIO_TPIC2810 is not set + +# +# MFD GPIO expanders +# +# CONFIG_GPIO_ADP5520 is not set +# CONFIG_GPIO_CRYSTAL_COVE is not set +# CONFIG_GPIO_DA9052 is not set +# CONFIG_GPIO_DA9055 is not set +CONFIG_GPIO_PALMAS=y +CONFIG_GPIO_RC5T583=y +CONFIG_GPIO_TPS6586X=y +CONFIG_GPIO_TPS65910=y +# CONFIG_GPIO_TPS65912 is not set +# CONFIG_GPIO_TWL4030 is not set +# CONFIG_GPIO_TWL6040 is not set +# CONFIG_GPIO_WHISKEY_COVE is not set +# CONFIG_GPIO_WM831X is not set +# CONFIG_GPIO_WM8350 is not set + +# +# PCI GPIO expanders +# +# CONFIG_GPIO_AMD8111 is not set +# CONFIG_GPIO_BT8XX is not set +# CONFIG_GPIO_ML_IOH is not set +# CONFIG_GPIO_PCI_IDIO_16 is not set +# CONFIG_GPIO_RDC321X is not set + +# +# SPI GPIO expanders +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MC33880 is not set +# CONFIG_GPIO_PISOSR is not set + +# +# SPI or I2C GPIO expanders +# + +# +# USB GPIO expanders +# +# CONFIG_W1 is not set +CONFIG_POWER_AVS=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_RESTART=y +CONFIG_POWER_SUPPLY=y +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_PDA_POWER is not set +# CONFIG_MAX8925_POWER is not set +# CONFIG_WM831X_BACKUP is not set +# CONFIG_WM831X_POWER is not set +# CONFIG_WM8350_POWER is not set +# CONFIG_TEST_POWER is not set +# CONFIG_BATTERY_88PM860X is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2781 is not set +# CONFIG_BATTERY_DS2782 is not set +# CONFIG_BATTERY_SBS is not set +# CONFIG_CHARGER_SBS is not set +# CONFIG_BATTERY_BQ27XXX is not set +# CONFIG_BATTERY_DA9030 is not set +# CONFIG_BATTERY_DA9052 is not set +# CONFIG_BATTERY_MAX17040 is not set +# CONFIG_BATTERY_MAX17042 is not set +# CONFIG_CHARGER_MAX8903 is not set +# CONFIG_CHARGER_LP8727 is not set +# CONFIG_CHARGER_GPIO is not set +CONFIG_CHARGER_MANAGER=y +# CONFIG_CHARGER_MAX14577 is not set +# CONFIG_CHARGER_MAX77693 is not set +# CONFIG_CHARGER_BQ2415X is not set +# CONFIG_CHARGER_BQ24190 is not set +# CONFIG_CHARGER_BQ24257 is not set +# CONFIG_CHARGER_BQ24735 is not set +# CONFIG_CHARGER_BQ25890 is not set +# CONFIG_CHARGER_SMB347 is not set +# CONFIG_CHARGER_TPS65090 is not set +# CONFIG_BATTERY_GAUGE_LTC2941 is not set +# CONFIG_CHARGER_RT9455 is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_HWMON_DEBUG_CHIP is not set + +# +# Native drivers +# +# CONFIG_SENSORS_ABITUGURU is not set +# CONFIG_SENSORS_ABITUGURU3 is not set +# CONFIG_SENSORS_AD7314 is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7310 is not set +# CONFIG_SENSORS_ADT7410 is not set +# CONFIG_SENSORS_ADT7411 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7475 is not set +# CONFIG_SENSORS_ASC7621 is not set +# CONFIG_SENSORS_K8TEMP is not set +# CONFIG_SENSORS_K10TEMP is not set +# CONFIG_SENSORS_FAM15H_POWER is not set +# CONFIG_SENSORS_APPLESMC is not set +# CONFIG_SENSORS_ASB100 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS620 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_DELL_SMM is not set +# CONFIG_SENSORS_DA9052_ADC is not set +# CONFIG_SENSORS_DA9055 is not set +# CONFIG_SENSORS_I5K_AMB is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_FSCHMD is not set +# CONFIG_SENSORS_FTSTEUTATES is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_G760A is not set +# CONFIG_SENSORS_G762 is not set +# CONFIG_SENSORS_GPIO_FAN is not set +# CONFIG_SENSORS_HIH6130 is not set +# CONFIG_SENSORS_I5500 is not set +CONFIG_SENSORS_CORETEMP=m +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_JC42 is not set +# CONFIG_SENSORS_POWR1220 is not set +# CONFIG_SENSORS_LINEAGE is not set +# CONFIG_SENSORS_LTC2945 is not set +# CONFIG_SENSORS_LTC2990 is not set +# CONFIG_SENSORS_LTC4151 is not set +# CONFIG_SENSORS_LTC4215 is not set +# CONFIG_SENSORS_LTC4222 is not set +# CONFIG_SENSORS_LTC4245 is not set +# CONFIG_SENSORS_LTC4260 is not set +# CONFIG_SENSORS_LTC4261 is not set +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX16065 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX1668 is not set +# CONFIG_SENSORS_MAX197 is not set +# CONFIG_SENSORS_MAX31722 is not set +# CONFIG_SENSORS_MAX6639 is not set +# CONFIG_SENSORS_MAX6642 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_MAX6697 is not set +# CONFIG_SENSORS_MAX31790 is not set +# CONFIG_SENSORS_MCP3021 is not set +# CONFIG_SENSORS_TC654 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +# CONFIG_SENSORS_LM73 is not set +# CONFIG_SENSORS_LM75 is not set +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +# CONFIG_SENSORS_LM95234 is not set +# CONFIG_SENSORS_LM95241 is not set +# CONFIG_SENSORS_LM95245 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_NTC_THERMISTOR is not set +# CONFIG_SENSORS_NCT6683 is not set +# CONFIG_SENSORS_NCT6775 is not set +# CONFIG_SENSORS_NCT7802 is not set +# CONFIG_SENSORS_NCT7904 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_PMBUS is not set +# CONFIG_SENSORS_SHT15 is not set +# CONFIG_SENSORS_SHT21 is not set +# CONFIG_SENSORS_SHT3x is not set +# CONFIG_SENSORS_SHTC1 is not set +# CONFIG_SENSORS_SIS5595 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_EMC1403 is not set +# CONFIG_SENSORS_EMC2103 is not set +# CONFIG_SENSORS_EMC6W201 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +# CONFIG_SENSORS_SCH56XX_COMMON is not set +# CONFIG_SENSORS_SCH5627 is not set +# CONFIG_SENSORS_SCH5636 is not set +# CONFIG_SENSORS_STTS751 is not set +# CONFIG_SENSORS_SMM665 is not set +# CONFIG_SENSORS_ADC128D818 is not set +# CONFIG_SENSORS_ADS1015 is not set +# CONFIG_SENSORS_ADS7828 is not set +# CONFIG_SENSORS_ADS7871 is not set +# CONFIG_SENSORS_AMC6821 is not set +# CONFIG_SENSORS_INA209 is not set +# CONFIG_SENSORS_INA2XX is not set +# CONFIG_SENSORS_INA3221 is not set +# CONFIG_SENSORS_TC74 is not set +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_TMP102 is not set +# CONFIG_SENSORS_TMP103 is not set +# CONFIG_SENSORS_TMP108 is not set +# CONFIG_SENSORS_TMP401 is not set +# CONFIG_SENSORS_TMP421 is not set +# CONFIG_SENSORS_VIA_CPUTEMP is not set +# CONFIG_SENSORS_VIA686A is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_VT8231 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83795 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +# CONFIG_SENSORS_WM831X is not set +# CONFIG_SENSORS_WM8350 is not set +# CONFIG_SENSORS_XGENE is not set + +# +# ACPI drivers +# +# CONFIG_SENSORS_ACPI_POWER is not set +# CONFIG_SENSORS_ATK0110 is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_WRITABLE_TRIPS=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set +# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set +# CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set +CONFIG_THERMAL_GOV_FAIR_SHARE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_BANG_BANG=y +CONFIG_THERMAL_GOV_USER_SPACE=y +CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y +CONFIG_THERMAL_EMULATION=y +CONFIG_INTEL_POWERCLAMP=m +# CONFIG_X86_PKG_TEMP_THERMAL is not set +# CONFIG_INTEL_SOC_DTS_THERMAL is not set + +# +# ACPI INT340X thermal drivers +# +# CONFIG_INT340X_THERMAL is not set +# CONFIG_INTEL_BXT_PMIC_THERMAL is not set +# CONFIG_INTEL_PCH_THERMAL is not set +CONFIG_WATCHDOG=y +CONFIG_WATCHDOG_CORE=y +# CONFIG_WATCHDOG_NOWAYOUT is not set +CONFIG_WATCHDOG_SYSFS=y + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +# CONFIG_DA9052_WATCHDOG is not set +# CONFIG_DA9055_WATCHDOG is not set +# CONFIG_DA9063_WATCHDOG is not set +# CONFIG_WDAT_WDT is not set +# CONFIG_WM831X_WATCHDOG is not set +# CONFIG_WM8350_WATCHDOG is not set +# CONFIG_XILINX_WATCHDOG is not set +# CONFIG_ZIIRAVE_WATCHDOG is not set +# CONFIG_CADENCE_WATCHDOG is not set +# CONFIG_DW_WATCHDOG is not set +# CONFIG_TWL4030_WATCHDOG is not set +# CONFIG_MAX63XX_WATCHDOG is not set +# CONFIG_ACQUIRE_WDT is not set +# CONFIG_ADVANTECH_WDT is not set +# CONFIG_ALIM1535_WDT is not set +# CONFIG_ALIM7101_WDT is not set +# CONFIG_EBC_C384_WDT is not set +# CONFIG_F71808E_WDT is not set +# CONFIG_SP5100_TCO is not set +# CONFIG_SBC_FITPC2_WATCHDOG is not set +# CONFIG_EUROTECH_WDT is not set +# CONFIG_IB700_WDT is not set +# CONFIG_IBMASR is not set +# CONFIG_WAFER_WDT is not set +# CONFIG_I6300ESB_WDT is not set +# CONFIG_IE6XX_WDT is not set +# CONFIG_ITCO_WDT is not set +# CONFIG_IT8712F_WDT is not set +# CONFIG_IT87_WDT is not set +# CONFIG_HP_WATCHDOG is not set +# CONFIG_SC1200_WDT is not set +# CONFIG_PC87413_WDT is not set +# CONFIG_NV_TCO is not set +# CONFIG_60XX_WDT is not set +# CONFIG_CPU5_WDT is not set +# CONFIG_SMSC_SCH311X_WDT is not set +# CONFIG_SMSC37B787_WDT is not set +# CONFIG_VIA_WDT is not set +# CONFIG_W83627HF_WDT is not set +# CONFIG_W83877F_WDT is not set +# CONFIG_W83977F_WDT is not set +# CONFIG_MACHZ_WDT is not set +# CONFIG_SBC_EPX_C3_WATCHDOG is not set +# CONFIG_NI903X_WDT is not set +# CONFIG_NIC7018_WDT is not set +# CONFIG_MEN_A21_WDT is not set +# CONFIG_XEN_WDT is not set + +# +# PCI-based Watchdog Cards +# +# CONFIG_PCIPCWATCHDOG is not set +# CONFIG_WDTPCI is not set + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set + +# +# Watchdog Pretimeout Governors +# +# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set +CONFIG_BCMA_POSSIBLE=y + +# +# Broadcom specific AMBA +# +# CONFIG_BCMA is not set + +# +# Multifunction device drivers +# +CONFIG_MFD_CORE=y +CONFIG_MFD_AS3711=y +CONFIG_PMIC_ADP5520=y +CONFIG_MFD_AAT2870_CORE=y +# CONFIG_MFD_BCM590XX is not set +# CONFIG_MFD_AXP20X_I2C is not set +# CONFIG_MFD_CROS_EC is not set +CONFIG_PMIC_DA903X=y +CONFIG_PMIC_DA9052=y +CONFIG_MFD_DA9052_SPI=y +CONFIG_MFD_DA9052_I2C=y +CONFIG_MFD_DA9055=y +# CONFIG_MFD_DA9062 is not set +CONFIG_MFD_DA9063=y +# CONFIG_MFD_DA9150 is not set +# CONFIG_MFD_DLN2 is not set +# CONFIG_MFD_MC13XXX_SPI is not set +# CONFIG_MFD_MC13XXX_I2C is not set +# CONFIG_HTC_PASIC3 is not set +CONFIG_HTC_I2CPLD=y +# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set +# CONFIG_LPC_ICH is not set +# CONFIG_LPC_SCH is not set +CONFIG_INTEL_SOC_PMIC=y +# CONFIG_MFD_INTEL_LPSS_ACPI is not set +# CONFIG_MFD_INTEL_LPSS_PCI is not set +# CONFIG_MFD_JANZ_CMODIO is not set +# CONFIG_MFD_KEMPLD is not set +# CONFIG_MFD_88PM800 is not set +# CONFIG_MFD_88PM805 is not set +CONFIG_MFD_88PM860X=y +CONFIG_MFD_MAX14577=y +CONFIG_MFD_MAX77693=y +CONFIG_MFD_MAX77843=y +# CONFIG_MFD_MAX8907 is not set +CONFIG_MFD_MAX8925=y +CONFIG_MFD_MAX8997=y +CONFIG_MFD_MAX8998=y +# CONFIG_MFD_MT6397 is not set +# CONFIG_MFD_MENF21BMC is not set +CONFIG_EZX_PCAP=y +# CONFIG_MFD_VIPERBOARD is not set +# CONFIG_MFD_RETU is not set +# CONFIG_MFD_PCF50633 is not set +# CONFIG_MFD_RDC321X is not set +# CONFIG_MFD_RTSX_PCI is not set +# CONFIG_MFD_RT5033 is not set +# CONFIG_MFD_RTSX_USB is not set +CONFIG_MFD_RC5T583=y +CONFIG_MFD_SEC_CORE=y +# CONFIG_MFD_SI476X_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_SKY81452 is not set +CONFIG_MFD_SMSC=y +CONFIG_ABX500_CORE=y +CONFIG_AB3100_CORE=y +# CONFIG_AB3100_OTP is not set +CONFIG_MFD_SYSCON=y +# CONFIG_MFD_TI_AM335X_TSCADC is not set +# CONFIG_MFD_LP3943 is not set +CONFIG_MFD_LP8788=y +CONFIG_MFD_PALMAS=y +# CONFIG_TPS6105X is not set +# CONFIG_TPS65010 is not set +# CONFIG_TPS6507X is not set +# CONFIG_MFD_TPS65086 is not set +CONFIG_MFD_TPS65090=y +# CONFIG_MFD_TPS65217 is not set +# CONFIG_MFD_TI_LP873X is not set +# CONFIG_MFD_TPS65218 is not set +CONFIG_MFD_TPS6586X=y +CONFIG_MFD_TPS65910=y +CONFIG_MFD_TPS65912=y +CONFIG_MFD_TPS65912_I2C=y +CONFIG_MFD_TPS65912_SPI=y +CONFIG_MFD_TPS80031=y +CONFIG_TWL4030_CORE=y +CONFIG_MFD_TWL4030_AUDIO=y +CONFIG_TWL6040_CORE=y +# CONFIG_MFD_WL1273_CORE is not set +# CONFIG_MFD_LM3533 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_VX855 is not set +# CONFIG_MFD_ARIZONA_I2C is not set +# CONFIG_MFD_ARIZONA_SPI is not set +CONFIG_MFD_WM8400=y +CONFIG_MFD_WM831X=y +CONFIG_MFD_WM831X_I2C=y +CONFIG_MFD_WM831X_SPI=y +CONFIG_MFD_WM8350=y +CONFIG_MFD_WM8350_I2C=y +# CONFIG_MFD_WM8994 is not set +CONFIG_REGULATOR=y +# CONFIG_REGULATOR_DEBUG is not set +# CONFIG_REGULATOR_FIXED_VOLTAGE is not set +# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set +# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set +# CONFIG_REGULATOR_88PM8607 is not set +# CONFIG_REGULATOR_ACT8865 is not set +# CONFIG_REGULATOR_AD5398 is not set +# CONFIG_REGULATOR_ANATOP is not set +# CONFIG_REGULATOR_AAT2870 is not set +# CONFIG_REGULATOR_AB3100 is not set +# CONFIG_REGULATOR_AS3711 is not set +# CONFIG_REGULATOR_DA903X is not set +# CONFIG_REGULATOR_DA9052 is not set +# CONFIG_REGULATOR_DA9055 is not set +# CONFIG_REGULATOR_DA9063 is not set +# CONFIG_REGULATOR_DA9210 is not set +# CONFIG_REGULATOR_DA9211 is not set +# CONFIG_REGULATOR_FAN53555 is not set +# CONFIG_REGULATOR_GPIO is not set +# CONFIG_REGULATOR_ISL9305 is not set +# CONFIG_REGULATOR_ISL6271A is not set +# CONFIG_REGULATOR_LP3971 is not set +# CONFIG_REGULATOR_LP3972 is not set +# CONFIG_REGULATOR_LP872X is not set +# CONFIG_REGULATOR_LP8755 is not set +# CONFIG_REGULATOR_LP8788 is not set +# CONFIG_REGULATOR_LTC3589 is not set +# CONFIG_REGULATOR_LTC3676 is not set +# CONFIG_REGULATOR_MAX14577 is not set +# CONFIG_REGULATOR_MAX1586 is not set +# CONFIG_REGULATOR_MAX8649 is not set +# CONFIG_REGULATOR_MAX8660 is not set +# CONFIG_REGULATOR_MAX8925 is not set +# CONFIG_REGULATOR_MAX8952 is not set +# CONFIG_REGULATOR_MAX8997 is not set +# CONFIG_REGULATOR_MAX8998 is not set +# CONFIG_REGULATOR_MAX77693 is not set +# CONFIG_REGULATOR_MT6311 is not set +# CONFIG_REGULATOR_PALMAS is not set +# CONFIG_REGULATOR_PCAP is not set +# CONFIG_REGULATOR_PFUZE100 is not set +# CONFIG_REGULATOR_PV88060 is not set +# CONFIG_REGULATOR_PV88080 is not set +# CONFIG_REGULATOR_PV88090 is not set +# CONFIG_REGULATOR_PWM is not set +# CONFIG_REGULATOR_RC5T583 is not set +# CONFIG_REGULATOR_S2MPA01 is not set +# CONFIG_REGULATOR_S2MPS11 is not set +# CONFIG_REGULATOR_S5M8767 is not set +# CONFIG_REGULATOR_TPS51632 is not set +# CONFIG_REGULATOR_TPS62360 is not set +# CONFIG_REGULATOR_TPS65023 is not set +# CONFIG_REGULATOR_TPS6507X is not set +# CONFIG_REGULATOR_TPS65090 is not set +# CONFIG_REGULATOR_TPS6524X is not set +# CONFIG_REGULATOR_TPS6586X is not set +# CONFIG_REGULATOR_TPS65910 is not set +# CONFIG_REGULATOR_TPS65912 is not set +# CONFIG_REGULATOR_TPS80031 is not set +# CONFIG_REGULATOR_TWL4030 is not set +# CONFIG_REGULATOR_WM831X is not set +# CONFIG_REGULATOR_WM8350 is not set +# CONFIG_REGULATOR_WM8400 is not set +# CONFIG_MEDIA_SUPPORT is not set + +# +# Graphics support +# +CONFIG_AGP=y +CONFIG_AGP_AMD64=y +CONFIG_AGP_INTEL=y +# CONFIG_AGP_SIS is not set +CONFIG_AGP_VIA=y +CONFIG_INTEL_GTT=y +CONFIG_VGA_ARB=y +CONFIG_VGA_ARB_MAX_GPUS=16 +CONFIG_VGA_SWITCHEROO=y +CONFIG_DRM=m +CONFIG_DRM_DP_AUX_CHARDEV=y +# CONFIG_DRM_DEBUG_MM_SELFTEST is not set +CONFIG_DRM_KMS_HELPER=m +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_FBDEV_EMULATION=y +CONFIG_DRM_LOAD_EDID_FIRMWARE=y +CONFIG_DRM_TTM=m + +# +# I2C encoder or helper chips +# +# CONFIG_DRM_I2C_CH7006 is not set +# CONFIG_DRM_I2C_SIL164 is not set +# CONFIG_DRM_I2C_NXP_TDA998X is not set +# CONFIG_DRM_RADEON is not set +# CONFIG_DRM_AMDGPU is not set + +# +# ACP (Audio CoProcessor) Configuration +# +# CONFIG_DRM_NOUVEAU is not set +# CONFIG_DRM_I915 is not set +# CONFIG_DRM_VGEM is not set +CONFIG_DRM_VMWGFX=m +CONFIG_DRM_VMWGFX_FBCON=y +# CONFIG_DRM_GMA500 is not set +# CONFIG_DRM_UDL is not set +# CONFIG_DRM_AST is not set +# CONFIG_DRM_MGAG200 is not set +# CONFIG_DRM_CIRRUS_QEMU is not set +# CONFIG_DRM_QXL is not set +# CONFIG_DRM_BOCHS is not set +# CONFIG_DRM_VIRTIO_GPU is not set +CONFIG_DRM_BRIDGE=y + +# +# Display Interface Bridges +# +# CONFIG_DRM_ANALOGIX_ANX78XX is not set +# CONFIG_DRM_HISI_HIBMC is not set +# CONFIG_DRM_TINYDRM is not set +# CONFIG_DRM_LEGACY is not set +# CONFIG_DRM_LIB_RANDOM is not set + +# +# Frame buffer Devices +# +CONFIG_FB=y +CONFIG_FIRMWARE_EDID=y +CONFIG_FB_CMDLINE=y +CONFIG_FB_NOTIFY=y +# CONFIG_FB_DDC is not set +CONFIG_FB_BOOT_VESA_SUPPORT=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_IMAGEBLIT=y +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set +CONFIG_FB_SYS_FILLRECT=m +CONFIG_FB_SYS_COPYAREA=m +CONFIG_FB_SYS_IMAGEBLIT=m +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set +# CONFIG_FB_FOREIGN_ENDIAN is not set +CONFIG_FB_SYS_FOPS=m +CONFIG_FB_DEFERRED_IO=y +# CONFIG_FB_SVGALIB is not set +# CONFIG_FB_MACMODES is not set +# CONFIG_FB_BACKLIGHT is not set +CONFIG_FB_MODE_HELPERS=y +CONFIG_FB_TILEBLITTING=y + +# +# Frame buffer hardware drivers +# +# CONFIG_FB_CIRRUS is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set +# CONFIG_FB_ARC is not set +CONFIG_FB_ASILIANT=y +CONFIG_FB_IMSTT=y +# CONFIG_FB_VGA16 is not set +# CONFIG_FB_UVESA is not set +CONFIG_FB_VESA=y +CONFIG_FB_EFI=y +# CONFIG_FB_N411 is not set +# CONFIG_FB_HGA is not set +# CONFIG_FB_OPENCORES is not set +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_NVIDIA is not set +# CONFIG_FB_RIVA is not set +# CONFIG_FB_I740 is not set +# CONFIG_FB_LE80578 is not set +# CONFIG_FB_INTEL is not set +# CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON is not set +# CONFIG_FB_ATY128 is not set +# CONFIG_FB_ATY is not set +# CONFIG_FB_S3 is not set +# CONFIG_FB_SAVAGE is not set +# CONFIG_FB_SIS is not set +# CONFIG_FB_VIA is not set +# CONFIG_FB_NEOMAGIC is not set +# CONFIG_FB_KYRO is not set +# CONFIG_FB_3DFX is not set +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VT8623 is not set +# CONFIG_FB_TRIDENT is not set +# CONFIG_FB_ARK is not set +# CONFIG_FB_PM3 is not set +# CONFIG_FB_CARMINE is not set +# CONFIG_FB_SMSCUFX is not set +# CONFIG_FB_UDL is not set +# CONFIG_FB_IBM_GXT4500 is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_XEN_FBDEV_FRONTEND is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_BROADSHEET is not set +# CONFIG_FB_AUO_K190X is not set +CONFIG_FB_SIMPLE=y +# CONFIG_FB_SM712 is not set +CONFIG_BACKLIGHT_LCD_SUPPORT=y +# CONFIG_LCD_CLASS_DEVICE is not set +CONFIG_BACKLIGHT_CLASS_DEVICE=y +# CONFIG_BACKLIGHT_GENERIC is not set +# CONFIG_BACKLIGHT_PWM is not set +# CONFIG_BACKLIGHT_DA903X is not set +# CONFIG_BACKLIGHT_DA9052 is not set +# CONFIG_BACKLIGHT_MAX8925 is not set +# CONFIG_BACKLIGHT_APPLE is not set +# CONFIG_BACKLIGHT_PM8941_WLED is not set +# CONFIG_BACKLIGHT_SAHARA is not set +# CONFIG_BACKLIGHT_WM831X is not set +# CONFIG_BACKLIGHT_ADP5520 is not set +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set +# CONFIG_BACKLIGHT_88PM860X is not set +# CONFIG_BACKLIGHT_AAT2870 is not set +# CONFIG_BACKLIGHT_LM3630A is not set +# CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_LP855X is not set +# CONFIG_BACKLIGHT_LP8788 is not set +# CONFIG_BACKLIGHT_PANDORA is not set +# CONFIG_BACKLIGHT_AS3711 is not set +# CONFIG_BACKLIGHT_GPIO is not set +# CONFIG_BACKLIGHT_LV5207LP is not set +# CONFIG_BACKLIGHT_BD6107 is not set +# CONFIG_VGASTATE is not set +CONFIG_HDMI=y + +# +# Console display driver support +# +CONFIG_VGA_CONSOLE=y +# CONFIG_VGACON_SOFT_SCROLLBACK is not set +CONFIG_DUMMY_CONSOLE=y +CONFIG_DUMMY_CONSOLE_COLUMNS=80 +CONFIG_DUMMY_CONSOLE_ROWS=25 +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +# CONFIG_LOGO is not set +# CONFIG_SOUND is not set + +# +# HID support +# +# CONFIG_HID is not set + +# +# USB HID support +# +# CONFIG_USB_HID is not set +CONFIG_HID_PID=y + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set + +# +# I2C HID support +# +# CONFIG_I2C_HID is not set + +# +# Intel ISH HID support +# +# CONFIG_INTEL_ISH_HID is not set +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_COMMON=y +CONFIG_USB_ARCH_HAS_HCD=y +CONFIG_USB=y +CONFIG_USB_ANNOUNCE_NEW_DEVICES=y + +# +# Miscellaneous USB options +# +CONFIG_USB_DEFAULT_PERSIST=y +CONFIG_USB_DYNAMIC_MINORS=y +# CONFIG_USB_OTG is not set +# CONFIG_USB_OTG_WHITELIST is not set +# CONFIG_USB_OTG_BLACKLIST_HUB is not set +# CONFIG_USB_LEDS_TRIGGER_USBPORT is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +# CONFIG_USB_XHCI_PLATFORM is not set +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_ROOT_HUB_TT=y +CONFIG_USB_EHCI_TT_NEWSCHED=y +CONFIG_USB_EHCI_PCI=y +CONFIG_USB_EHCI_HCD_PLATFORM=y +# CONFIG_USB_OXU210HP_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_ISP1362_HCD is not set +# CONFIG_USB_FOTG210_HCD is not set +# CONFIG_USB_MAX3421_HCD is not set +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_HCD_PCI=y +CONFIG_USB_OHCI_HCD_PLATFORM=y +CONFIG_USB_UHCI_HCD=y +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HCD_TEST_MODE is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may +# + +# +# also be needed; see USB_STORAGE Help for more info +# +# CONFIG_USB_STORAGE is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set +# CONFIG_USBIP_CORE is not set +# CONFIG_USB_MUSB_HDRC is not set +# CONFIG_USB_DWC3 is not set +CONFIG_USB_DWC2=y +CONFIG_USB_DWC2_HOST=y + +# +# Gadget/Dual-role mode requires USB Gadget support to be enabled +# +# CONFIG_USB_DWC2_PCI is not set +# CONFIG_USB_DWC2_DEBUG is not set +# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set +# CONFIG_USB_CHIPIDEA is not set +# CONFIG_USB_ISP1760 is not set + +# +# USB port drivers +# +# CONFIG_USB_USS720 is not set +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_SISUSBVGA is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_EHSET_TEST_FIXTURE is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_YUREX is not set +# CONFIG_USB_EZUSB_FX2 is not set +# CONFIG_USB_HUB_USB251XB is not set +# CONFIG_USB_HSIC_USB3503 is not set +# CONFIG_USB_HSIC_USB4604 is not set +# CONFIG_USB_LINK_LAYER_TEST is not set +# CONFIG_USB_CHAOSKEY is not set +# CONFIG_UCSI is not set + +# +# USB Physical Layer drivers +# +# CONFIG_USB_PHY is not set +# CONFIG_NOP_USB_XCEIV is not set +# CONFIG_USB_GPIO_VBUS is not set +# CONFIG_USB_ISP1301 is not set +# CONFIG_USB_GADGET is not set +CONFIG_USB_LED_TRIG=y +# CONFIG_USB_ULPI_BUS is not set +# CONFIG_UWB is not set +CONFIG_MMC=y +# CONFIG_MMC_DEBUG is not set +# CONFIG_MMC_BLOCK is not set +# CONFIG_SDIO_UART is not set +# CONFIG_MMC_TEST is not set + +# +# MMC/SD/SDIO Host Controller Drivers +# +# CONFIG_MMC_SDHCI is not set +# CONFIG_MMC_WBSD is not set +# CONFIG_MMC_TIFM_SD is not set +# CONFIG_MMC_SPI is not set +# CONFIG_MMC_CB710 is not set +# CONFIG_MMC_VIA_SDMMC is not set +# CONFIG_MMC_VUB300 is not set +# CONFIG_MMC_USHC is not set +# CONFIG_MMC_USDHI6ROL0 is not set +# CONFIG_MMC_TOSHIBA_PCI is not set +# CONFIG_MMC_MTK is not set +# CONFIG_MEMSTICK is not set +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y +# CONFIG_LEDS_CLASS_FLASH is not set +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set + +# +# LED drivers +# +# CONFIG_LEDS_88PM860X is not set +# CONFIG_LEDS_LM3530 is not set +# CONFIG_LEDS_LM3642 is not set +# CONFIG_LEDS_PCA9532 is not set +# CONFIG_LEDS_GPIO is not set +# CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_LP3952 is not set +# CONFIG_LEDS_LP5521 is not set +# CONFIG_LEDS_LP5523 is not set +# CONFIG_LEDS_LP5562 is not set +# CONFIG_LEDS_LP8501 is not set +# CONFIG_LEDS_LP8788 is not set +# CONFIG_LEDS_LP8860 is not set +# CONFIG_LEDS_CLEVO_MAIL is not set +# CONFIG_LEDS_PCA955X is not set +# CONFIG_LEDS_PCA963X is not set +# CONFIG_LEDS_WM831X_STATUS is not set +# CONFIG_LEDS_WM8350 is not set +# CONFIG_LEDS_DA903X is not set +# CONFIG_LEDS_DA9052 is not set +# CONFIG_LEDS_DAC124S085 is not set +# CONFIG_LEDS_PWM is not set +# CONFIG_LEDS_REGULATOR is not set +# CONFIG_LEDS_BD2802 is not set +# CONFIG_LEDS_INTEL_SS4200 is not set +# CONFIG_LEDS_LT3593 is not set +# CONFIG_LEDS_ADP5520 is not set +# CONFIG_LEDS_TCA6507 is not set +# CONFIG_LEDS_TLC591XX is not set +# CONFIG_LEDS_MAX8997 is not set +# CONFIG_LEDS_LM355x is not set + +# +# LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM) +# +# CONFIG_LEDS_BLINKM is not set +# CONFIG_LEDS_MLXCPLD is not set +# CONFIG_LEDS_USER is not set +# CONFIG_LEDS_NIC78BX is not set + +# +# LED Triggers +# +CONFIG_LEDS_TRIGGERS=y +# CONFIG_LEDS_TRIGGER_TIMER is not set +# CONFIG_LEDS_TRIGGER_ONESHOT is not set +CONFIG_LEDS_TRIGGER_DISK=y +# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +CONFIG_LEDS_TRIGGER_CPU=y +# CONFIG_LEDS_TRIGGER_GPIO is not set +# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set + +# +# iptables trigger is under Netfilter config (LED target) +# +# CONFIG_LEDS_TRIGGER_TRANSIENT is not set +# CONFIG_LEDS_TRIGGER_CAMERA is not set +CONFIG_LEDS_TRIGGER_PANIC=y +# CONFIG_ACCESSIBILITY is not set +# CONFIG_INFINIBAND is not set +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_EDAC=y +# CONFIG_EDAC_LEGACY_SYSFS is not set +# CONFIG_EDAC_DEBUG is not set +# CONFIG_EDAC_DECODE_MCE is not set +# CONFIG_EDAC_MM_EDAC is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_MC146818_LIB=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_HCTOSYS=y +CONFIG_RTC_HCTOSYS_DEVICE="rtc0" +CONFIG_RTC_SYSTOHC=y +CONFIG_RTC_SYSTOHC_DEVICE="rtc0" +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_88PM860X is not set +# CONFIG_RTC_DRV_ABB5ZES3 is not set +# CONFIG_RTC_DRV_ABX80X is not set +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_LP8788 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_MAX8925 is not set +# CONFIG_RTC_DRV_MAX8998 is not set +# CONFIG_RTC_DRV_MAX8997 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_ISL12022 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8523 is not set +# CONFIG_RTC_DRV_PCF85063 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_BQ32K is not set +# CONFIG_RTC_DRV_PALMAS is not set +# CONFIG_RTC_DRV_TPS6586X is not set +# CONFIG_RTC_DRV_TPS65910 is not set +# CONFIG_RTC_DRV_TPS80031 is not set +# CONFIG_RTC_DRV_RC5T583 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8010 is not set +# CONFIG_RTC_DRV_RX8581 is not set +# CONFIG_RTC_DRV_RX8025 is not set +# CONFIG_RTC_DRV_EM3027 is not set +# CONFIG_RTC_DRV_RV8803 is not set +# CONFIG_RTC_DRV_S5M is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T93 is not set +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1302 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1343 is not set +# CONFIG_RTC_DRV_DS1347 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6916 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RX4581 is not set +# CONFIG_RTC_DRV_RX6110 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_PCF2123 is not set +# CONFIG_RTC_DRV_MCP795 is not set +CONFIG_RTC_I2C_AND_SPI=y + +# +# SPI and I2C RTC drivers +# +# CONFIG_RTC_DRV_DS3232 is not set +# CONFIG_RTC_DRV_PCF2127 is not set +# CONFIG_RTC_DRV_RV3029C2 is not set + +# +# Platform RTC drivers +# +CONFIG_RTC_DRV_CMOS=y +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1685_FAMILY is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_DS2404 is not set +# CONFIG_RTC_DRV_DA9052 is not set +# CONFIG_RTC_DRV_DA9055 is not set +# CONFIG_RTC_DRV_DA9063 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_MSM6242 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_RP5C01 is not set +# CONFIG_RTC_DRV_V3020 is not set +# CONFIG_RTC_DRV_WM831X is not set +# CONFIG_RTC_DRV_WM8350 is not set +# CONFIG_RTC_DRV_AB3100 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PCAP is not set + +# +# HID Sensor RTC drivers +# +CONFIG_DMADEVICES=y +# CONFIG_DMADEVICES_DEBUG is not set + +# +# DMA Devices +# +CONFIG_DMA_ENGINE=y +CONFIG_DMA_ACPI=y +# CONFIG_INTEL_IDMA64 is not set +# CONFIG_INTEL_IOATDMA is not set +# CONFIG_QCOM_HIDMA_MGMT is not set +# CONFIG_QCOM_HIDMA is not set +CONFIG_DW_DMAC_CORE=y +# CONFIG_DW_DMAC is not set +CONFIG_DW_DMAC_PCI=y + +# +# DMA Clients +# +CONFIG_ASYNC_TX_DMA=y +# CONFIG_DMATEST is not set + +# +# DMABUF options +# +CONFIG_SYNC_FILE=y +# CONFIG_SW_SYNC is not set +CONFIG_AUXDISPLAY=y +# CONFIG_KS0108 is not set +# CONFIG_IMG_ASCII_LCD is not set +# CONFIG_UIO is not set +# CONFIG_VFIO is not set +CONFIG_VIRT_DRIVERS=y +CONFIG_VIRTIO=y + +# +# Virtio drivers +# +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_PCI_LEGACY=y +CONFIG_VIRTIO_BALLOON=y +# CONFIG_VIRTIO_INPUT is not set +CONFIG_VIRTIO_MMIO=y +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y + +# +# Microsoft Hyper-V guest support +# +# CONFIG_HYPERV is not set + +# +# Xen driver support +# +CONFIG_XEN_BALLOON=y +CONFIG_XEN_SELFBALLOONING=y +CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y +CONFIG_XEN_BALLOON_MEMORY_HOTPLUG_LIMIT=512 +CONFIG_XEN_SCRUB_PAGES=y +# CONFIG_XEN_DEV_EVTCHN is not set +CONFIG_XEN_BACKEND=y +# CONFIG_XENFS is not set +CONFIG_XEN_SYS_HYPERVISOR=y +CONFIG_XEN_XENBUS_FRONTEND=y +# CONFIG_XEN_GNTDEV is not set +# CONFIG_XEN_GRANT_DEV_ALLOC is not set +CONFIG_SWIOTLB_XEN=y +CONFIG_XEN_TMEM=m +# CONFIG_XEN_PCIDEV_BACKEND is not set +CONFIG_XEN_PRIVCMD=m +CONFIG_XEN_ACPI_PROCESSOR=y +CONFIG_XEN_MCE_LOG=y +CONFIG_XEN_HAVE_PVMMU=y +CONFIG_XEN_EFI=y +CONFIG_XEN_AUTO_XLATE=y +CONFIG_XEN_ACPI=y +CONFIG_XEN_HAVE_VPMU=y +CONFIG_STAGING=y +# CONFIG_COMEDI is not set +# CONFIG_RTL8192U is not set +# CONFIG_RTLLIB is not set +# CONFIG_R8712U is not set +# CONFIG_RTS5208 is not set +# CONFIG_FB_SM750 is not set +# CONFIG_FB_XGI is not set + +# +# Speakup console speech +# +# CONFIG_SPEAKUP is not set +CONFIG_STAGING_MEDIA=y + +# +# Android +# +# CONFIG_LTE_GDM724X is not set +# CONFIG_LNET is not set +# CONFIG_DGNC is not set +# CONFIG_GS_FPGABOOT is not set +CONFIG_CRYPTO_SKEIN=y +CONFIG_UNISYSSPAR=y +# CONFIG_UNISYS_VISORBUS is not set +# CONFIG_FB_TFT is not set +# CONFIG_MOST is not set +# CONFIG_KS7010 is not set +# CONFIG_GREYBUS is not set +CONFIG_X86_PLATFORM_DEVICES=y +# CONFIG_ACERHDF is not set +# CONFIG_ASUS_LAPTOP is not set +# CONFIG_DELL_LAPTOP is not set +# CONFIG_DELL_SMO8800 is not set +# CONFIG_DELL_RBTN is not set +# CONFIG_FUJITSU_LAPTOP is not set +# CONFIG_FUJITSU_TABLET is not set +# CONFIG_AMILO_RFKILL is not set +# CONFIG_HP_ACCEL is not set +# CONFIG_HP_WIRELESS is not set +# CONFIG_MSI_LAPTOP is not set +# CONFIG_PANASONIC_LAPTOP is not set +# CONFIG_COMPAL_LAPTOP is not set +# CONFIG_SONY_LAPTOP is not set +# CONFIG_IDEAPAD_LAPTOP is not set +# CONFIG_THINKPAD_ACPI is not set +# CONFIG_SENSORS_HDAPS is not set +# CONFIG_INTEL_MENLOW is not set +# CONFIG_EEEPC_LAPTOP is not set +# CONFIG_ASUS_WIRELESS is not set +# CONFIG_ACPI_WMI is not set +# CONFIG_TOPSTAR_LAPTOP is not set +# CONFIG_TOSHIBA_BT_RFKILL is not set +# CONFIG_TOSHIBA_HAPS is not set +# CONFIG_ACPI_CMPC is not set +# CONFIG_INTEL_HID_EVENT is not set +# CONFIG_INTEL_VBTN is not set +# CONFIG_INTEL_IPS is not set +CONFIG_INTEL_PMC_CORE=y +# CONFIG_IBM_RTL is not set +# CONFIG_SAMSUNG_LAPTOP is not set +# CONFIG_INTEL_OAKTRAIL is not set +# CONFIG_SAMSUNG_Q10 is not set +# CONFIG_APPLE_GMUX is not set +# CONFIG_INTEL_RST is not set +# CONFIG_INTEL_SMARTCONNECT is not set +# CONFIG_PVPANIC is not set +# CONFIG_INTEL_PMC_IPC is not set +# CONFIG_SURFACE_PRO3_BUTTON is not set +# CONFIG_INTEL_PUNIT_IPC is not set +# CONFIG_MLX_PLATFORM is not set +# CONFIG_MLX_CPLD_PLATFORM is not set +# CONFIG_INTEL_TURBO_MAX_3 is not set +# CONFIG_SILEAD_DMI is not set +CONFIG_PMC_ATOM=y +CONFIG_CHROME_PLATFORMS=y +# CONFIG_CHROMEOS_LAPTOP is not set +# CONFIG_CHROMEOS_PSTORE is not set +# CONFIG_CROS_KBD_LED_BACKLIGHT is not set +CONFIG_CLKDEV_LOOKUP=y +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_COMMON_CLK=y + +# +# Common Clock Framework +# +# CONFIG_COMMON_CLK_WM831X is not set +# CONFIG_COMMON_CLK_SI5351 is not set +# CONFIG_COMMON_CLK_CDCE706 is not set +# CONFIG_COMMON_CLK_CS2000_CP is not set +# CONFIG_COMMON_CLK_S2MPS11 is not set +# CONFIG_CLK_TWL6040 is not set +# CONFIG_COMMON_CLK_NXP is not set +# CONFIG_COMMON_CLK_PALMAS is not set +# CONFIG_COMMON_CLK_PWM is not set +# CONFIG_COMMON_CLK_PXA is not set +# CONFIG_COMMON_CLK_PIC32 is not set + +# +# Hardware Spinlock drivers +# + +# +# Clock Source drivers +# +CONFIG_CLKEVT_I8253=y +CONFIG_I8253_LOCK=y +CONFIG_CLKBLD_I8253=y +# CONFIG_ATMEL_PIT is not set +# CONFIG_SH_TIMER_CMT is not set +# CONFIG_SH_TIMER_MTU2 is not set +# CONFIG_SH_TIMER_TMU is not set +# CONFIG_EM_TIMER_STI is not set +CONFIG_MAILBOX=y +CONFIG_PCC=y +# CONFIG_ALTERA_MBOX is not set +CONFIG_IOMMU_API=y +CONFIG_IOMMU_SUPPORT=y + +# +# Generic IOMMU Pagetable Support +# +CONFIG_IOMMU_IOVA=y +CONFIG_AMD_IOMMU=y +# CONFIG_AMD_IOMMU_V2 is not set +CONFIG_DMAR_TABLE=y +CONFIG_INTEL_IOMMU=y +CONFIG_INTEL_IOMMU_SVM=y +# CONFIG_INTEL_IOMMU_DEFAULT_ON is not set +CONFIG_INTEL_IOMMU_FLOPPY_WA=y +CONFIG_IRQ_REMAP=y + +# +# Remoteproc drivers +# +# CONFIG_REMOTEPROC is not set + +# +# Rpmsg drivers +# + +# +# SOC (System On Chip) specific Drivers +# + +# +# Broadcom SoC drivers +# +# CONFIG_SUNXI_SRAM is not set +CONFIG_SOC_TI=y +# CONFIG_SOC_ZTE is not set +CONFIG_PM_DEVFREQ=y + +# +# DEVFREQ Governors +# +CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y +CONFIG_DEVFREQ_GOV_PERFORMANCE=y +CONFIG_DEVFREQ_GOV_POWERSAVE=y +CONFIG_DEVFREQ_GOV_USERSPACE=y +CONFIG_DEVFREQ_GOV_PASSIVE=y + +# +# DEVFREQ Drivers +# +CONFIG_PM_DEVFREQ_EVENT=y +CONFIG_EXTCON=y + +# +# Extcon Device Drivers +# +# CONFIG_EXTCON_GPIO is not set +# CONFIG_EXTCON_INTEL_INT3496 is not set +# CONFIG_EXTCON_MAX14577 is not set +# CONFIG_EXTCON_MAX3355 is not set +# CONFIG_EXTCON_MAX77693 is not set +# CONFIG_EXTCON_MAX77843 is not set +# CONFIG_EXTCON_MAX8997 is not set +# CONFIG_EXTCON_PALMAS is not set +# CONFIG_EXTCON_QCOM_SPMI_MISC is not set +# CONFIG_EXTCON_RT8973A is not set +# CONFIG_EXTCON_SM5502 is not set +# CONFIG_EXTCON_USB_GPIO is not set +CONFIG_MEMORY=y +# CONFIG_IIO is not set +# CONFIG_NTB is not set +CONFIG_VME_BUS=y + +# +# VME Bridge Drivers +# +# CONFIG_VME_CA91CX42 is not set +# CONFIG_VME_TSI148 is not set +# CONFIG_VME_FAKE is not set + +# +# VME Board Drivers +# +# CONFIG_VMIVME_7805 is not set + +# +# VME Device Drivers +# +# CONFIG_VME_USER is not set +# CONFIG_VME_PIO2 is not set +CONFIG_PWM=y +CONFIG_PWM_SYSFS=y +CONFIG_PWM_CRC=y +# CONFIG_PWM_LPSS_PCI is not set +# CONFIG_PWM_LPSS_PLATFORM is not set +# CONFIG_PWM_PCA9685 is not set +# CONFIG_PWM_TWL is not set +# CONFIG_PWM_TWL_LED is not set +CONFIG_ARM_GIC_MAX_NR=1 +# CONFIG_IPACK_BUS is not set +CONFIG_RESET_CONTROLLER=y +# CONFIG_RESET_ATH79 is not set +# CONFIG_RESET_BERLIN is not set +# CONFIG_RESET_LPC18XX is not set +# CONFIG_RESET_MESON is not set +# CONFIG_RESET_PISTACHIO is not set +# CONFIG_RESET_SOCFPGA is not set +# CONFIG_RESET_STM32 is not set +# CONFIG_RESET_SUNXI is not set +# CONFIG_TI_SYSCON_RESET is not set +# CONFIG_RESET_ZYNQ is not set +# CONFIG_RESET_TEGRA_BPMP is not set +# CONFIG_FMC is not set + +# +# PHY Subsystem +# +CONFIG_GENERIC_PHY=y +# CONFIG_PHY_PXA_28NM_HSIC is not set +# CONFIG_PHY_PXA_28NM_USB2 is not set +# CONFIG_BCM_KONA_USB2_PHY is not set +# CONFIG_PHY_SAMSUNG_USB2 is not set +CONFIG_POWERCAP=y +# CONFIG_INTEL_RAPL is not set +# CONFIG_MCB is not set + +# +# Performance monitor support +# +CONFIG_RAS=y +# CONFIG_MCE_AMD_INJ is not set +# CONFIG_THUNDERBOLT is not set + +# +# Android +# +# CONFIG_ANDROID is not set +CONFIG_LIBNVDIMM=y +# CONFIG_BLK_DEV_PMEM is not set +# CONFIG_ND_BLK is not set +CONFIG_ND_CLAIM=y +CONFIG_BTT=y +CONFIG_NVDIMM_PFN=y +CONFIG_NVDIMM_DAX=y +# CONFIG_DEV_DAX is not set +# CONFIG_NVMEM is not set +# CONFIG_STM is not set +# CONFIG_INTEL_TH is not set + +# +# FPGA Configuration Support +# +# CONFIG_FPGA is not set + +# +# FSI support +# +# CONFIG_FSI is not set + +# +# Firmware Drivers +# +CONFIG_EDD=y +CONFIG_EDD_OFF=y +CONFIG_FIRMWARE_MEMMAP=y +# CONFIG_DELL_RBU is not set +# CONFIG_DCDBAS is not set +CONFIG_DMIID=y +# CONFIG_DMI_SYSFS is not set +CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y +CONFIG_ISCSI_IBFT_FIND=y +# CONFIG_ISCSI_IBFT is not set +# CONFIG_FW_CFG_SYSFS is not set +# CONFIG_GOOGLE_FIRMWARE is not set + +# +# EFI (Extensible Firmware Interface) Support +# +CONFIG_EFI_VARS=y +CONFIG_EFI_ESRT=y +# CONFIG_EFI_VARS_PSTORE is not set +CONFIG_EFI_RUNTIME_MAP=y +# CONFIG_EFI_FAKE_MEMMAP is not set +CONFIG_EFI_RUNTIME_WRAPPERS=y +# CONFIG_EFI_BOOTLOADER_CONTROL is not set +# CONFIG_EFI_CAPSULE_LOADER is not set +# CONFIG_EFI_TEST is not set +# CONFIG_APPLE_PROPERTIES is not set +CONFIG_UEFI_CPER=y +# CONFIG_EFI_DEV_PATH_PARSER is not set + +# +# Tegra firmware driver +# + +# +# File systems +# +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_FS_IOMAP=y +# CONFIG_EXT2_FS is not set +# CONFIG_EXT3_FS is not set +CONFIG_EXT4_FS=y +CONFIG_EXT4_USE_FOR_EXT2=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_EXT4_ENCRYPTION=y +CONFIG_EXT4_FS_ENCRYPTION=y +# CONFIG_EXT4_DEBUG is not set +CONFIG_JBD2=y +# CONFIG_JBD2_DEBUG is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_XFS_FS is not set +# CONFIG_GFS2_FS is not set +# CONFIG_BTRFS_FS is not set +# CONFIG_NILFS2_FS is not set +# CONFIG_F2FS_FS is not set +CONFIG_FS_DAX=y +CONFIG_FS_DAX_PMD=y +CONFIG_FS_POSIX_ACL=y +CONFIG_EXPORTFS=y +CONFIG_EXPORTFS_BLOCK_OPS=y +CONFIG_FILE_LOCKING=y +CONFIG_MANDATORY_FILE_LOCKING=y +CONFIG_FS_ENCRYPTION=y +CONFIG_FSNOTIFY=y +CONFIG_DNOTIFY=y +CONFIG_INOTIFY_USER=y +CONFIG_FANOTIFY=y +CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y +CONFIG_QUOTA=y +CONFIG_QUOTA_NETLINK_INTERFACE=y +# CONFIG_PRINT_QUOTA_WARNING is not set +# CONFIG_QUOTA_DEBUG is not set +# CONFIG_QFMT_V1 is not set +# CONFIG_QFMT_V2 is not set +CONFIG_QUOTACTL=y +CONFIG_QUOTACTL_COMPAT=y +CONFIG_AUTOFS4_FS=m +CONFIG_FUSE_FS=y +# CONFIG_CUSE is not set +# CONFIG_OVERLAY_FS is not set + +# +# Caches +# +# CONFIG_FSCACHE is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +# CONFIG_MSDOS_FS is not set +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +# CONFIG_FAT_DEFAULT_UTF8 is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y +CONFIG_PROC_VMCORE=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PROC_CHILDREN=y +CONFIG_KERNFS=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS_XATTR=y +CONFIG_HUGETLBFS=y +CONFIG_HUGETLB_PAGE=y +CONFIG_ARCH_HAS_GIGANTIC_PAGE=y +# CONFIG_CONFIGFS_FS is not set +CONFIG_EFIVAR_FS=y +CONFIG_MISC_FILESYSTEMS=y +# CONFIG_ORANGEFS_FS is not set +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +CONFIG_ECRYPT_FS=y +CONFIG_ECRYPT_FS_MESSAGING=y +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +# CONFIG_CRAMFS is not set +CONFIG_SQUASHFS=y +# CONFIG_SQUASHFS_FILE_CACHE is not set +CONFIG_SQUASHFS_FILE_DIRECT=y +# CONFIG_SQUASHFS_DECOMP_SINGLE is not set +# CONFIG_SQUASHFS_DECOMP_MULTI is not set +CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU=y +CONFIG_SQUASHFS_XATTR=y +CONFIG_SQUASHFS_ZLIB=y +CONFIG_SQUASHFS_LZ4=y +CONFIG_SQUASHFS_LZO=y +CONFIG_SQUASHFS_XZ=y +# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set +# CONFIG_SQUASHFS_EMBEDDED is not set +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_QNX6FS_FS is not set +# CONFIG_ROMFS_FS is not set +CONFIG_PSTORE=y +CONFIG_PSTORE_ZLIB_COMPRESS=y +# CONFIG_PSTORE_LZO_COMPRESS is not set +# CONFIG_PSTORE_LZ4_COMPRESS is not set +# CONFIG_PSTORE_CONSOLE is not set +# CONFIG_PSTORE_PMSG is not set +# CONFIG_PSTORE_FTRACE is not set +# CONFIG_PSTORE_RAM is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +# CONFIG_NFS_FS is not set +# CONFIG_NFSD is not set +# CONFIG_CEPH_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +# CONFIG_NLS_ASCII is not set +# CONFIG_NLS_ISO8859_1 is not set +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +# CONFIG_NLS_MAC_ROMAN is not set +# CONFIG_NLS_MAC_CELTIC is not set +# CONFIG_NLS_MAC_CENTEURO is not set +# CONFIG_NLS_MAC_CROATIAN is not set +# CONFIG_NLS_MAC_CYRILLIC is not set +# CONFIG_NLS_MAC_GAELIC is not set +# CONFIG_NLS_MAC_GREEK is not set +# CONFIG_NLS_MAC_ICELAND is not set +# CONFIG_NLS_MAC_INUIT is not set +# CONFIG_NLS_MAC_ROMANIAN is not set +# CONFIG_NLS_MAC_TURKISH is not set +# CONFIG_NLS_UTF8 is not set + +# +# Kernel hacking +# +CONFIG_TRACE_IRQFLAGS_SUPPORT=y + +# +# printk and dmesg options +# +CONFIG_PRINTK_TIME=y +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 +CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 +CONFIG_BOOT_PRINTK_DELAY=y +CONFIG_DYNAMIC_DEBUG=y + +# +# Compile-time checks and compiler options +# +CONFIG_DEBUG_INFO=y +# CONFIG_DEBUG_INFO_REDUCED is not set +# CONFIG_DEBUG_INFO_SPLIT is not set +CONFIG_DEBUG_INFO_DWARF4=y +CONFIG_GDB_SCRIPTS=y +# CONFIG_ENABLE_WARN_DEPRECATED is not set +# CONFIG_ENABLE_MUST_CHECK is not set +CONFIG_FRAME_WARN=1024 +# CONFIG_STRIP_ASM_SYMS is not set +# CONFIG_READABLE_ASM is not set +CONFIG_UNUSED_SYMBOLS=y +# CONFIG_PAGE_OWNER is not set +CONFIG_DEBUG_FS=y +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_SECTION_MISMATCH is not set +CONFIG_SECTION_MISMATCH_WARN_ONLY=y +CONFIG_ARCH_WANT_FRAME_POINTERS=y +CONFIG_FRAME_POINTER=y +# CONFIG_STACK_VALIDATION is not set +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set +CONFIG_MAGIC_SYSRQ=y +CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x01b6 +CONFIG_MAGIC_SYSRQ_SERIAL=y +CONFIG_DEBUG_KERNEL=y + +# +# Memory Debugging +# +# CONFIG_PAGE_EXTENSION is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_PAGE_POISONING is not set +# CONFIG_DEBUG_PAGE_REF is not set +# CONFIG_DEBUG_RODATA_TEST is not set +# CONFIG_DEBUG_OBJECTS is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_HAVE_DEBUG_KMEMLEAK=y +# CONFIG_DEBUG_KMEMLEAK is not set +# CONFIG_DEBUG_STACK_USAGE is not set +# CONFIG_DEBUG_VM is not set +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +# CONFIG_DEBUG_VIRTUAL is not set +# CONFIG_DEBUG_MEMORY_INIT is not set +# CONFIG_DEBUG_PER_CPU_MAPS is not set +CONFIG_HAVE_DEBUG_STACKOVERFLOW=y +# CONFIG_DEBUG_STACKOVERFLOW is not set +CONFIG_HAVE_ARCH_KMEMCHECK=y +CONFIG_HAVE_ARCH_KASAN=y +# CONFIG_KASAN is not set +CONFIG_ARCH_HAS_KCOV=y +# CONFIG_KCOV is not set +# CONFIG_DEBUG_SHIRQ is not set + +# +# Debug Lockups and Hangs +# +CONFIG_LOCKUP_DETECTOR=y +CONFIG_HARDLOCKUP_DETECTOR=y +# CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is not set +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE=0 +# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set +CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set +CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0 +# CONFIG_WQ_WATCHDOG is not set +# CONFIG_PANIC_ON_OOPS is not set +CONFIG_PANIC_ON_OOPS_VALUE=0 +CONFIG_PANIC_TIMEOUT=0 +CONFIG_SCHED_DEBUG=y +CONFIG_SCHED_INFO=y +CONFIG_SCHEDSTATS=y +CONFIG_SCHED_STACK_END_CHECK=y +# CONFIG_DEBUG_TIMEKEEPING is not set + +# +# Lock Debugging (spinlocks, mutexes, etc...) +# +# CONFIG_DEBUG_RT_MUTEXES is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_MUTEXES is not set +# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set +# CONFIG_DEBUG_LOCK_ALLOC is not set +# CONFIG_PROVE_LOCKING is not set +# CONFIG_LOCK_STAT is not set +# CONFIG_DEBUG_ATOMIC_SLEEP is not set +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set +# CONFIG_LOCK_TORTURE_TEST is not set +# CONFIG_WW_MUTEX_SELFTEST is not set +CONFIG_STACKTRACE=y +# CONFIG_DEBUG_KOBJECT is not set +CONFIG_DEBUG_BUGVERBOSE=y +# CONFIG_DEBUG_LIST is not set +# CONFIG_DEBUG_PI_LIST is not set +# CONFIG_DEBUG_SG is not set +# CONFIG_DEBUG_NOTIFIERS is not set +# CONFIG_DEBUG_CREDENTIALS is not set + +# +# RCU Debugging +# +# CONFIG_PROVE_RCU is not set +# CONFIG_SPARSE_RCU_POINTER is not set +# CONFIG_TORTURE_TEST is not set +# CONFIG_RCU_PERF_TEST is not set +# CONFIG_RCU_TORTURE_TEST is not set +CONFIG_RCU_CPU_STALL_TIMEOUT=60 +# CONFIG_RCU_TRACE is not set +# CONFIG_RCU_EQS_DEBUG is not set +# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_NOTIFIER_ERROR_INJECTION is not set +# CONFIG_FAULT_INJECTION is not set +# CONFIG_LATENCYTOP is not set +CONFIG_USER_STACKTRACE_SUPPORT=y +CONFIG_NOP_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y +CONFIG_HAVE_FENTRY=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_TRACER_MAX_TRACE=y +CONFIG_TRACE_CLOCK=y +CONFIG_RING_BUFFER=y +CONFIG_EVENT_TRACING=y +CONFIG_CONTEXT_SWITCH_TRACER=y +CONFIG_TRACING=y +CONFIG_GENERIC_TRACER=y +CONFIG_TRACING_SUPPORT=y +CONFIG_FTRACE=y +CONFIG_FUNCTION_TRACER=y +CONFIG_FUNCTION_GRAPH_TRACER=y +# CONFIG_IRQSOFF_TRACER is not set +CONFIG_SCHED_TRACER=y +# CONFIG_HWLAT_TRACER is not set +CONFIG_FTRACE_SYSCALLS=y +CONFIG_TRACER_SNAPSHOT=y +# CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP is not set +CONFIG_BRANCH_PROFILE_NONE=y +# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set +# CONFIG_PROFILE_ALL_BRANCHES is not set +CONFIG_STACK_TRACER=y +CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_KPROBE_EVENTS=y +# CONFIG_UPROBE_EVENTS is not set +CONFIG_BPF_EVENTS=y +CONFIG_PROBE_EVENTS=y +CONFIG_DYNAMIC_FTRACE=y +CONFIG_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_FUNCTION_PROFILER=y +CONFIG_FTRACE_MCOUNT_RECORD=y +# CONFIG_FTRACE_STARTUP_TEST is not set +CONFIG_MMIOTRACE=y +CONFIG_TRACING_MAP=y +CONFIG_HIST_TRIGGERS=y +# CONFIG_MMIOTRACE_TEST is not set +# CONFIG_TRACEPOINT_BENCHMARK is not set +# CONFIG_RING_BUFFER_BENCHMARK is not set +# CONFIG_RING_BUFFER_STARTUP_TEST is not set +# CONFIG_TRACE_ENUM_MAP_FILE is not set +CONFIG_TRACING_EVENTS_GPIO=y + +# +# Runtime Testing +# +# CONFIG_LKDTM is not set +# CONFIG_TEST_LIST_SORT is not set +# CONFIG_TEST_SORT is not set +# CONFIG_KPROBES_SANITY_TEST is not set +# CONFIG_BACKTRACE_SELF_TEST is not set +# CONFIG_RBTREE_TEST is not set +# CONFIG_INTERVAL_TREE_TEST is not set +# CONFIG_PERCPU_TEST is not set +# CONFIG_ATOMIC64_SELFTEST is not set +# CONFIG_TEST_HEXDUMP is not set +# CONFIG_TEST_STRING_HELPERS is not set +# CONFIG_TEST_KSTRTOX is not set +# CONFIG_TEST_PRINTF is not set +# CONFIG_TEST_BITMAP is not set +# CONFIG_TEST_UUID is not set +# CONFIG_TEST_RHASHTABLE is not set +# CONFIG_TEST_HASH is not set +# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set +# CONFIG_DMA_API_DEBUG is not set +# CONFIG_TEST_LKM is not set +# CONFIG_TEST_USER_COPY is not set +# CONFIG_TEST_BPF is not set +# CONFIG_TEST_FIRMWARE is not set +# CONFIG_TEST_UDELAY is not set +CONFIG_MEMTEST=y +# CONFIG_TEST_STATIC_KEYS is not set +# CONFIG_BUG_ON_DATA_CORRUPTION is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +CONFIG_KGDB=y +CONFIG_KGDB_SERIAL_CONSOLE=y +# CONFIG_KGDB_TESTS is not set +CONFIG_KGDB_LOW_LEVEL_TRAP=y +CONFIG_KGDB_KDB=y +CONFIG_KDB_DEFAULT_ENABLE=0x1 +CONFIG_KDB_KEYBOARD=y +CONFIG_KDB_CONTINUE_CATASTROPHIC=0 +CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y +# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set +# CONFIG_UBSAN is not set +CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y +CONFIG_STRICT_DEVMEM=y +# CONFIG_IO_STRICT_DEVMEM is not set +# CONFIG_X86_VERBOSE_BOOTUP is not set +CONFIG_EARLY_PRINTK=y +CONFIG_EARLY_PRINTK_DBGP=y +CONFIG_EARLY_PRINTK_EFI=y +CONFIG_X86_PTDUMP_CORE=y +# CONFIG_X86_PTDUMP is not set +# CONFIG_EFI_PGT_DUMP is not set +CONFIG_DEBUG_WX=y +CONFIG_DOUBLEFAULT=y +# CONFIG_DEBUG_TLBFLUSH is not set +# CONFIG_IOMMU_DEBUG is not set +# CONFIG_IOMMU_STRESS is not set +CONFIG_HAVE_MMIOTRACE_SUPPORT=y +# CONFIG_X86_DECODER_SELFTEST is not set +CONFIG_IO_DELAY_TYPE_0X80=0 +CONFIG_IO_DELAY_TYPE_0XED=1 +CONFIG_IO_DELAY_TYPE_UDELAY=2 +CONFIG_IO_DELAY_TYPE_NONE=3 +# CONFIG_IO_DELAY_0X80 is not set +CONFIG_IO_DELAY_0XED=y +# CONFIG_IO_DELAY_UDELAY is not set +# CONFIG_IO_DELAY_NONE is not set +CONFIG_DEFAULT_IO_DELAY_TYPE=1 +# CONFIG_DEBUG_BOOT_PARAMS is not set +# CONFIG_CPA_DEBUG is not set +CONFIG_OPTIMIZE_INLINING=y +# CONFIG_DEBUG_ENTRY is not set +# CONFIG_DEBUG_NMI_SELFTEST is not set +CONFIG_X86_DEBUG_FPU=y +# CONFIG_PUNIT_ATOM_DEBUG is not set + +# +# Security options +# +CONFIG_KEYS=y +CONFIG_PERSISTENT_KEYRINGS=y +CONFIG_BIG_KEYS=y +CONFIG_TRUSTED_KEYS=y +CONFIG_ENCRYPTED_KEYS=y +CONFIG_KEY_DH_OPERATIONS=y +# CONFIG_SECURITY_DMESG_RESTRICT is not set +CONFIG_SECURITY=y +CONFIG_SECURITYFS=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_PATH=y +CONFIG_INTEL_TXT=y +CONFIG_LSM_MMAP_MIN_ADDR=0 +CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y +CONFIG_HAVE_ARCH_HARDENED_USERCOPY=y +CONFIG_HARDENED_USERCOPY=y +# CONFIG_HARDENED_USERCOPY_PAGESPAN is not set +# CONFIG_STATIC_USERMODEHELPER is not set +CONFIG_SECURITY_SELINUX=y +CONFIG_SECURITY_SELINUX_BOOTPARAM=y +CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0 +CONFIG_SECURITY_SELINUX_DISABLE=y +CONFIG_SECURITY_SELINUX_DEVELOP=y +CONFIG_SECURITY_SELINUX_AVC_STATS=y +CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1 +CONFIG_SECURITY_SMACK=y +# CONFIG_SECURITY_SMACK_BRINGUP is not set +CONFIG_SECURITY_SMACK_NETFILTER=y +# CONFIG_SECURITY_SMACK_APPEND_SIGNALS is not set +CONFIG_SECURITY_TOMOYO=y +CONFIG_SECURITY_TOMOYO_MAX_ACCEPT_ENTRY=2048 +CONFIG_SECURITY_TOMOYO_MAX_AUDIT_LOG=1024 +# CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER is not set +CONFIG_SECURITY_TOMOYO_POLICY_LOADER="/sbin/tomoyo-init" +CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER="/sbin/init" +CONFIG_SECURITY_APPARMOR=y +CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1 +CONFIG_SECURITY_APPARMOR_HASH=y +CONFIG_SECURITY_APPARMOR_HASH_DEFAULT=y +# CONFIG_SECURITY_APPARMOR_DEBUG is not set +# CONFIG_SECURITY_LOADPIN is not set +CONFIG_SECURITY_YAMA=y +CONFIG_INTEGRITY=y +CONFIG_INTEGRITY_SIGNATURE=y +CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y +CONFIG_INTEGRITY_TRUSTED_KEYRING=y +CONFIG_INTEGRITY_AUDIT=y +CONFIG_IMA=y +CONFIG_IMA_MEASURE_PCR_IDX=10 +CONFIG_IMA_LSM_RULES=y +# CONFIG_IMA_TEMPLATE is not set +CONFIG_IMA_NG_TEMPLATE=y +# CONFIG_IMA_SIG_TEMPLATE is not set +CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng" +CONFIG_IMA_DEFAULT_HASH_SHA1=y +# CONFIG_IMA_DEFAULT_HASH_SHA256 is not set +# CONFIG_IMA_DEFAULT_HASH_SHA512 is not set +CONFIG_IMA_DEFAULT_HASH="sha1" +CONFIG_IMA_WRITE_POLICY=y +CONFIG_IMA_READ_POLICY=y +CONFIG_IMA_APPRAISE=y +CONFIG_IMA_TRUSTED_KEYRING=y +CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY=y +CONFIG_IMA_BLACKLIST_KEYRING=y +# CONFIG_IMA_LOAD_X509 is not set +CONFIG_EVM=y +CONFIG_EVM_ATTR_FSUUID=y +CONFIG_EVM_EXTRA_SMACK_XATTRS=y +# CONFIG_EVM_LOAD_X509 is not set +# CONFIG_DEFAULT_SECURITY_SELINUX is not set +# CONFIG_DEFAULT_SECURITY_SMACK is not set +# CONFIG_DEFAULT_SECURITY_TOMOYO is not set +CONFIG_DEFAULT_SECURITY_APPARMOR=y +# CONFIG_DEFAULT_SECURITY_DAC is not set +CONFIG_DEFAULT_SECURITY="apparmor" +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_ACOMP2=y +CONFIG_CRYPTO_RSA=y +# CONFIG_CRYPTO_DH is not set +# CONFIG_CRYPTO_ECDH is not set +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_USER is not set +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y +CONFIG_CRYPTO_GF128MUL=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +# CONFIG_CRYPTO_PCRYPT is not set +CONFIG_CRYPTO_WORKQUEUE=y +CONFIG_CRYPTO_CRYPTD=m +# CONFIG_CRYPTO_MCRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set +CONFIG_CRYPTO_ENGINE=m + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_CHACHA20POLY1305 is not set +CONFIG_CRYPTO_SEQIV=y +# CONFIG_CRYPTO_ECHAINIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +CONFIG_CRYPTO_CTR=y +CONFIG_CRYPTO_CTS=y +CONFIG_CRYPTO_ECB=y +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +CONFIG_CRYPTO_XTS=y +# CONFIG_CRYPTO_KEYWRAP is not set + +# +# Hash modes +# +# CONFIG_CRYPTO_CMAC is not set +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set +# CONFIG_CRYPTO_VMAC is not set + +# +# Digest +# +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CRC32C_INTEL=y +# CONFIG_CRYPTO_CRC32 is not set +CONFIG_CRYPTO_CRC32_PCLMUL=m +CONFIG_CRYPTO_CRCT10DIF=y +CONFIG_CRYPTO_CRCT10DIF_PCLMUL=m +# CONFIG_CRYPTO_GHASH is not set +# CONFIG_CRYPTO_POLY1305 is not set +# CONFIG_CRYPTO_POLY1305_X86_64 is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA1_SSSE3 is not set +# CONFIG_CRYPTO_SHA256_SSSE3 is not set +# CONFIG_CRYPTO_SHA512_SSSE3 is not set +# CONFIG_CRYPTO_SHA1_MB is not set +# CONFIG_CRYPTO_SHA256_MB is not set +# CONFIG_CRYPTO_SHA512_MB is not set +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_SHA512=y +# CONFIG_CRYPTO_SHA3 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set +CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL=m + +# +# Ciphers +# +CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_AES_TI is not set +# CONFIG_CRYPTO_AES_X86_64 is not set +# CONFIG_CRYPTO_AES_NI_INTEL is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_BLOWFISH_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAMELLIA_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64 is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST5_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAST6 is not set +# CONFIG_CRYPTO_CAST6_AVX_X86_64 is not set +# CONFIG_CRYPTO_DES is not set +# CONFIG_CRYPTO_DES3_EDE_X86_64 is not set +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SALSA20_X86_64 is not set +# CONFIG_CRYPTO_CHACHA20 is not set +# CONFIG_CRYPTO_CHACHA20_X86_64 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_SERPENT_SSE2_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX2_X86_64 is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set +# CONFIG_CRYPTO_TWOFISH_X86_64 is not set +# CONFIG_CRYPTO_TWOFISH_X86_64_3WAY is not set +# CONFIG_CRYPTO_TWOFISH_AVX_X86_64 is not set + +# +# Compression +# +# CONFIG_CRYPTO_DEFLATE is not set +CONFIG_CRYPTO_LZO=y +# CONFIG_CRYPTO_842 is not set +# CONFIG_CRYPTO_LZ4 is not set +# CONFIG_CRYPTO_LZ4HC is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_HASH=y +CONFIG_CRYPTO_DRBG_CTR=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_JITTERENTROPY=y +# CONFIG_CRYPTO_USER_API_HASH is not set +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set +# CONFIG_CRYPTO_USER_API_RNG is not set +# CONFIG_CRYPTO_USER_API_AEAD is not set +CONFIG_CRYPTO_HASH_INFO=y +CONFIG_CRYPTO_HW=y +CONFIG_CRYPTO_DEV_PADLOCK=y +# CONFIG_CRYPTO_DEV_PADLOCK_AES is not set +# CONFIG_CRYPTO_DEV_PADLOCK_SHA is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API_DESC is not set +CONFIG_CRYPTO_DEV_CCP=y +# CONFIG_CRYPTO_DEV_CCP_DD is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCC is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXX is not set +# CONFIG_CRYPTO_DEV_QAT_C62X is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCCVF is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXXVF is not set +# CONFIG_CRYPTO_DEV_QAT_C62XVF is not set +CONFIG_CRYPTO_DEV_VIRTIO=m +CONFIG_ASYMMETRIC_KEY_TYPE=y +CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y +CONFIG_X509_CERTIFICATE_PARSER=y +CONFIG_PKCS7_MESSAGE_PARSER=y +# CONFIG_PKCS7_TEST_KEY is not set +CONFIG_SIGNED_PE_FILE_VERIFICATION=y + +# +# Certificates for signature checking +# +CONFIG_MODULE_SIG_KEY="certs/signing_key.pem" +CONFIG_SYSTEM_TRUSTED_KEYRING=y +CONFIG_SYSTEM_TRUSTED_KEYS="" +CONFIG_SYSTEM_EXTRA_CERTIFICATE=y +CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=4096 +CONFIG_SECONDARY_TRUSTED_KEYRING=y +CONFIG_HAVE_KVM=y +CONFIG_VIRTUALIZATION=y +# CONFIG_KVM is not set +# CONFIG_VHOST_NET is not set +# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set +CONFIG_BINARY_PRINTF=y + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_HAVE_ARCH_BITREVERSE is not set +CONFIG_RATIONAL=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_NET_UTILS=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IO=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_HAS_FAST_MULTIPLIER=y +CONFIG_CRC_CCITT=y +CONFIG_CRC16=y +CONFIG_CRC_T10DIF=y +# CONFIG_CRC_ITU_T is not set +CONFIG_CRC32=y +# CONFIG_CRC32_SELFTEST is not set +CONFIG_CRC32_SLICEBY8=y +# CONFIG_CRC32_SLICEBY4 is not set +# CONFIG_CRC32_SARWATE is not set +# CONFIG_CRC32_BIT is not set +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +# CONFIG_CRC8 is not set +# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set +# CONFIG_RANDOM32_SELFTEST is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_XZ_DEC=y +CONFIG_XZ_DEC_X86=y +CONFIG_XZ_DEC_POWERPC=y +CONFIG_XZ_DEC_IA64=y +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_ARMTHUMB=y +CONFIG_XZ_DEC_SPARC=y +CONFIG_XZ_DEC_BCJ=y +# CONFIG_XZ_DEC_TEST is not set +CONFIG_DECOMPRESS_GZIP=y +CONFIG_DECOMPRESS_BZIP2=y +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DECOMPRESS_XZ=y +CONFIG_DECOMPRESS_LZO=y +CONFIG_DECOMPRESS_LZ4=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_RADIX_TREE_MULTIORDER=y +CONFIG_ASSOCIATIVE_ARRAY=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAS_DMA=y +# CONFIG_DMA_NOOP_OPS is not set +# CONFIG_DMA_VIRT_OPS is not set +CONFIG_CPU_RMAP=y +CONFIG_DQL=y +CONFIG_GLOB=y +# CONFIG_GLOB_SELFTEST is not set +CONFIG_NLATTR=y +CONFIG_CLZ_TAB=y +# CONFIG_CORDIC is not set +CONFIG_DDR=y +CONFIG_IRQ_POLL=y +CONFIG_MPILIB=y +CONFIG_SIGNATURE=y +CONFIG_OID_REGISTRY=y +CONFIG_UCS2_STRING=y +CONFIG_FONT_SUPPORT=y +# CONFIG_FONTS is not set +CONFIG_FONT_8x8=y +CONFIG_FONT_8x16=y +# CONFIG_SG_SPLIT is not set +CONFIG_SG_POOL=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_PMEM_API=y +CONFIG_ARCH_HAS_MMIO_FLUSH=y +CONFIG_SBITMAP=y diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_02/README.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_02/README.md new file mode 100644 index 0000000..43be631 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_02/README.md @@ -0,0 +1,6 @@ +Steps +===== + +- `make` +- `make modules_install` +- `make install` diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_03/Makefile b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_03/Makefile new file mode 100644 index 0000000..627053d --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_03/Makefile @@ -0,0 +1,1705 @@ +VERSION = 4 +PATCHLEVEL = 11 +SUBLEVEL = 0 +EXTRAVERSION = -eudyptula +NAME = Fearless Coyote + +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# o Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour); +# o Look for make include files relative to root of kernel src +MAKEFLAGS += -rR --include-dir=$(CURDIR) + +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC + +# Avoid interference with shell env settings +unexport GREP_OPTIONS + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.o targets which finally +# turn into vmlinux), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +# Beautify output +# --------------------------------------------------------------------------- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing will be printed at all, since +# the variable $(silent_cmd_cc_o_c) doesn't exist. +# +# A simple variant is to prefix commands with $(Q) - that's useful +# for commands that shall be hidden in non-verbose mode. +# +# $(Q)ln $@ :< +# +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. +# +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands + +ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif + +ifeq ($(KBUILD_VERBOSE),1) + quiet = + Q = +else + quiet=quiet_ + Q = @ +endif + +# If the user is running make -s (silent mode), suppress echoing of +# commands + +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) + quiet=silent_ + tools_silent=s +endif +else # make-3.8x +ifneq ($(filter s% -s%,$(MAKEFLAGS)),) + quiet=silent_ + tools_silent=-s +endif +endif + +export quiet Q KBUILD_VERBOSE + +# kbuild supports saving output files in a separate directory. +# To locate output files in a separate directory two syntaxes are supported. +# In both cases the working directory must be the root of the kernel src. +# 1) O= +# Use "make O=dir/to/store/output/files/" +# +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the directory +# where the output files shall be placed. +# export KBUILD_OUTPUT=dir/to/store/output/files/ +# make +# +# The O= assignment takes precedence over the KBUILD_OUTPUT environment +# variable. + +# KBUILD_SRC is set on invocation of make in OBJ directory +# KBUILD_SRC is not intended to be used by the regular user (for now) +ifeq ($(KBUILD_SRC),) + +# OK, Make called in directory where kernel src resides +# Do we want to locate output files in a separate directory? +ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT := $(O) +endif + +# That's our default target when none is given on the command line +PHONY := _all +_all: + +# Cancel implicit rules on top Makefile +$(CURDIR)/Makefile Makefile: ; + +ifneq ($(words $(subst :, ,$(CURDIR))), 1) + $(error main directory cannot contain spaces nor colons) +endif + +ifneq ($(KBUILD_OUTPUT),) +# Invoke a second make in the output directory, passing relevant variables +# check that the output directory actually exists +saved-output := $(KBUILD_OUTPUT) +KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ + && /bin/pwd) +$(if $(KBUILD_OUTPUT),, \ + $(error failed to create output directory "$(saved-output)")) + +PHONY += $(MAKECMDGOALS) sub-make + +$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make + @: + +sub-make: + $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ + -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) + +# Leave processing to above invocation of make +skip-makefile := 1 +endif # ifneq ($(KBUILD_OUTPUT),) +endif # ifeq ($(KBUILD_SRC),) + +# We process the rest of the Makefile if this is the final invocation of make +ifeq ($(skip-makefile),) + +# Do not print "Entering directory ...", +# but we want to display it when entering to the output directory +# so that IDEs/editors are able to understand relative filenames. +MAKEFLAGS += --no-print-directory + +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=1' to enable checking of only re-compiled files. +# Use 'make C=2' to enable checking of *all* source files, regardless +# of whether they are re-compiled or not. +# +# See the file "Documentation/sparse.txt" for more details, including +# where to get the "sparse" utility. + +ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC = $(C) +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 +endif + +# Use make M=dir to specify directory of external module to build +# Old syntax make ... SUBDIRS=$PWD is still supported +# Setting the environment variable KBUILD_EXTMOD take precedence +ifdef SUBDIRS + KBUILD_EXTMOD ?= $(SUBDIRS) +endif + +ifeq ("$(origin M)", "command line") + KBUILD_EXTMOD := $(M) +endif + +# If building an external module we do not care about the all: rule +# but instead _all depend on modules +PHONY += all +ifeq ($(KBUILD_EXTMOD),) +_all: all +else +_all: modules +endif + +ifeq ($(KBUILD_SRC),) + # building in the source tree + srctree := . +else + ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) + # building in a subdirectory of the source tree + srctree := .. + else + srctree := $(KBUILD_SRC) + endif +endif +objtree := . +src := $(srctree) +obj := $(objtree) + +VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) + +export srctree objtree VPATH + +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) + +# Cross compiling and selecting different set of gcc/bin-utils +# --------------------------------------------------------------------------- +# +# When performing cross compilation for other architectures ARCH shall be set +# to the target architecture. (See arch/* for the possibilities). +# ARCH can be set during invocation of make: +# make ARCH=ia64 +# Another way is to have ARCH set in the environment. +# The default ARCH is the host where make is executed. + +# CROSS_COMPILE specify the prefix used for all executables used +# during compilation. Only gcc and related bin-utils executables +# are prefixed with $(CROSS_COMPILE). +# CROSS_COMPILE can be set on the command line +# make CROSS_COMPILE=ia64-linux- +# Alternatively CROSS_COMPILE can be set in the environment. +# A third alternative is to store a setting in .config so that plain +# "make" in the configured kernel build directory always uses that. +# Default value for CROSS_COMPILE is not to prefix executables +# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile +ARCH ?= $(SUBARCH) +CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) + +# Architecture as present in compile.h +UTS_MACHINE := $(ARCH) +SRCARCH := $(ARCH) + +# Additional ARCH settings for x86 +ifeq ($(ARCH),i386) + SRCARCH := x86 +endif +ifeq ($(ARCH),x86_64) + SRCARCH := x86 +endif + +# Additional ARCH settings for sparc +ifeq ($(ARCH),sparc32) + SRCARCH := sparc +endif +ifeq ($(ARCH),sparc64) + SRCARCH := sparc +endif + +# Additional ARCH settings for sh +ifeq ($(ARCH),sh64) + SRCARCH := sh +endif + +# Additional ARCH settings for tile +ifeq ($(ARCH),tilepro) + SRCARCH := tile +endif +ifeq ($(ARCH),tilegx) + SRCARCH := tile +endif + +# Where to locate arch specific headers +hdr-arch := $(SRCARCH) + +KCONFIG_CONFIG ?= .config +export KCONFIG_CONFIG + +# SHELL used by kbuild +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOSTCC = gcc +HOSTCXX = g++ +HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 +HOSTCXXFLAGS = -O2 + +ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) +HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \ + -Wno-missing-field-initializers -fno-delete-null-pointer-checks +endif + +# Decide whether to build built-in, modular, or both. +# Normally, just do built-in. + +KBUILD_MODULES := +KBUILD_BUILTIN := 1 + +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are up to date before we record them. + +ifeq ($(MAKECMDGOALS),modules) + KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) +endif + +# If we have "make modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well + +ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) + KBUILD_MODULES := 1 +endif + +ifeq ($(MAKECMDGOALS),) + KBUILD_MODULES := 1 +endif + +export KBUILD_MODULES KBUILD_BUILTIN +export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD + +# We need some generic definitions (do not try to remake the file). +scripts/Kbuild.include: ; +include scripts/Kbuild.include + +# Make variables (CC, etc...) +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +AWK = awk +GENKSYMS = scripts/genksyms/genksyms +INSTALLKERNEL := installkernel +DEPMOD = /sbin/depmod +PERL = perl +PYTHON = python +CHECK = sparse + +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ + -Wbitwise -Wno-return-void $(CF) +NOSTDINC_FLAGS = +CFLAGS_MODULE = +AFLAGS_MODULE = +LDFLAGS_MODULE = +CFLAGS_KERNEL = +AFLAGS_KERNEL = +LDFLAGS_vmlinux = +CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) +CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) + + +# Use USERINCLUDE when you must reference the UAPI directories only. +USERINCLUDE := \ + -I$(srctree)/arch/$(hdr-arch)/include/uapi \ + -I$(objtree)/arch/$(hdr-arch)/include/generated/uapi \ + -I$(srctree)/include/uapi \ + -I$(objtree)/include/generated/uapi \ + -include $(srctree)/include/linux/kconfig.h + +# Use LINUXINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +LINUXINCLUDE := \ + -I$(srctree)/arch/$(hdr-arch)/include \ + -I$(objtree)/arch/$(hdr-arch)/include/generated/uapi \ + -I$(objtree)/arch/$(hdr-arch)/include/generated \ + $(if $(KBUILD_SRC), -I$(srctree)/include) \ + -I$(objtree)/include + +LINUXINCLUDE += $(filter-out $(LINUXINCLUDE),$(USERINCLUDE)) + +KBUILD_CPPFLAGS := -D__KERNEL__ + +KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration \ + -Wno-format-security \ + -std=gnu89 $(call cc-option,-fno-PIE) + + +KBUILD_AFLAGS_KERNEL := +KBUILD_CFLAGS_KERNEL := +KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) +KBUILD_AFLAGS_MODULE := -DMODULE +KBUILD_CFLAGS_MODULE := -DMODULE +KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds + +# Read KERNELRELEASE from include/config/kernel.release (if it exists) +KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) + +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION +export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC +export CPP AR NM STRIP OBJCOPY OBJDUMP +export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE +export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS + +export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS +export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KCOV CFLAGS_KASAN CFLAGS_UBSAN +export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE +export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE +export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL +export KBUILD_ARFLAGS + +# When compiling out-of-tree modules, put MODVERDIR in the module +# tree rather than in the kernel tree. The kernel tree might +# even be read-only. +export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions + +# Files to ignore in find ... statements + +export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ + -name CVS -o -name .pc -o -name .hg -o -name .git \) \ + -prune -o +export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ + --exclude CVS --exclude .pc --exclude .hg --exclude .git + +# =========================================================================== +# Rules shared between *config targets and build targets + +# Basic helpers built in scripts/ +PHONY += scripts_basic +scripts_basic: + $(Q)$(MAKE) $(build)=scripts/basic + $(Q)rm -f .tmp_quiet_recordmcount + +# To avoid any implicit rule to kick in, define an empty command. +scripts/basic/%: scripts_basic ; + +PHONY += outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +outputmakefile: +ifneq ($(KBUILD_SRC),) + $(Q)ln -fsn $(srctree) source + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) +endif + +# Support for using generic headers in asm-generic +PHONY += asm-generic +asm-generic: + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ + src=asm obj=arch/$(SRCARCH)/include/generated/asm + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ + src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm + +# To make sure we do not include .config for any of the *config targets +# catch them early, and hand them over to scripts/kconfig/Makefile +# It is allowed to specify more targets when calling make, including +# mixing *config targets and build targets. +# For example 'make oldconfig all'. +# Detect when mixed targets is specified, and make a second invocation +# of make so .config is not included in this case either (for *config). + +version_h := include/generated/uapi/linux/version.h +old_version_h := include/linux/version.h + +no-dot-config-targets := clean mrproper distclean \ + cscope gtags TAGS tags help% %docs check% coccicheck \ + $(version_h) headers_% archheaders archscripts \ + kernelversion %src-pkg + +config-targets := 0 +mixed-targets := 0 +dot-config := 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config := 0 + endif +endif + +ifeq ($(KBUILD_EXTMOD),) + ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets := 1 + ifneq ($(words $(MAKECMDGOALS)),1) + mixed-targets := 1 + endif + endif +endif +# install and module_install need also be processed one by one +ifneq ($(filter install,$(MAKECMDGOALS)),) + ifneq ($(filter modules_install,$(MAKECMDGOALS)),) + mixed-targets := 1 + endif +endif + +ifeq ($(mixed-targets),1) +# =========================================================================== +# We're called with mixed targets (*config and build targets). +# Handle them one by one. + +PHONY += $(MAKECMDGOALS) __build_one_by_one + +$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one + @: + +__build_one_by_one: + $(Q)set -e; \ + for i in $(MAKECMDGOALS); do \ + $(MAKE) -f $(srctree)/Makefile $$i; \ + done + +else +ifeq ($(config-targets),1) +# =========================================================================== +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target + +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig' +include arch/$(SRCARCH)/Makefile +export KBUILD_DEFCONFIG KBUILD_KCONFIG + +config: scripts_basic outputmakefile FORCE + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + +%config: scripts_basic outputmakefile FORCE + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + +else +# =========================================================================== +# Build targets only - this includes vmlinux, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +ifeq ($(KBUILD_EXTMOD),) +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parallel +PHONY += scripts +scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ + asm-generic gcc-plugins + $(Q)$(MAKE) $(build)=$(@) + +# Objects we will link into vmlinux / subdirs we need to visit +init-y := init/ +drivers-y := drivers/ sound/ firmware/ +net-y := net/ +libs-y := lib/ +core-y := usr/ +virt-y := virt/ +endif # KBUILD_EXTMOD + +ifeq ($(dot-config),1) +# Read in config +-include include/config/auto.conf + +ifeq ($(KBUILD_EXTMOD),) +# Read in dependencies to all Kconfig* files, make sure to run +# oldconfig if changes are detected. +-include include/config/auto.conf.cmd + +# To avoid any implicit rule to kick in, define an empty command +$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; + +# If .config is newer than include/config/auto.conf, someone tinkered +# with it and forgot to run make oldconfig. +# if auto.conf.cmd is missing then we are probably in a cleaned tree so +# we execute the config step to be sure to catch updated Kconfig files +include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd + $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig +else +# external modules needs include/generated/autoconf.h and include/config/auto.conf +# but do not care if they are up-to-date. Use auto.conf to trigger the test +PHONY += include/config/auto.conf + +include/config/auto.conf: + $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ + echo >&2; \ + echo >&2 " ERROR: Kernel configuration is invalid."; \ + echo >&2 " include/generated/autoconf.h or $@ are missing.";\ + echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ + echo >&2 ; \ + /bin/false) + +endif # KBUILD_EXTMOD + +else +# Dummy target needed, because used as prerequisite +include/config/auto.conf: ; +endif # $(dot-config) + +# For the kernel to actually contain only the needed exported symbols, +# we have to build modules as well to determine what those symbols are. +# (this can be evaluated only once include/config/auto.conf has been included) +ifdef CONFIG_TRIM_UNUSED_KSYMS + KBUILD_MODULES := 1 +endif + +# The all: target is the default when no target is given on the +# command line. +# This allow a user to issue only 'make' to build a kernel including modules +# Defaults to vmlinux, but the arch makefile usually adds further targets +all: vmlinux + +# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default +# values of the respective KBUILD_* variables +ARCH_CPPFLAGS := +ARCH_AFLAGS := +ARCH_CFLAGS := +include arch/$(SRCARCH)/Makefile + +KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) +KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) + +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,) +KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) +endif + +ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE +KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) +else +ifdef CONFIG_PROFILE_ALL_BRANCHES +KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,) +else +KBUILD_CFLAGS += -O2 +endif +endif + +KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ + $(call cc-disable-warning,maybe-uninitialized,)) + +# Tell gcc to never replace conditional load with a non-conditional one +KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) + +# check for 'asm goto' +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) + KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO + KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO +endif + +include scripts/Makefile.gcc-plugins + +ifdef CONFIG_READABLE_ASM +# Disable optimizations that make assembler listings hard to read. +# reorder blocks reorders the control in the function +# ipa clone creates specialized cloned functions +# partial inlining inlines only parts of functions +KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ + $(call cc-option,-fno-ipa-cp-clone,) \ + $(call cc-option,-fno-partial-inlining) +endif + +ifneq ($(CONFIG_FRAME_WARN),0) +KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) +endif + +# This selects the stack protector compiler flag. Testing it is delayed +# until after .config has been reprocessed, in the prepare-compiler-check +# target. +ifdef CONFIG_CC_STACKPROTECTOR_REGULAR + stackp-flag := -fstack-protector + stackp-name := REGULAR +else +ifdef CONFIG_CC_STACKPROTECTOR_STRONG + stackp-flag := -fstack-protector-strong + stackp-name := STRONG +else + # Force off for distro compilers that enable stack protector by default. + stackp-flag := $(call cc-option, -fno-stack-protector) +endif +endif +# Find arch-specific stack protector compiler sanity-checking script. +ifdef CONFIG_CC_STACKPROTECTOR + stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh + stackp-check := $(wildcard $(stackp-path)) +endif +KBUILD_CFLAGS += $(stackp-flag) + +ifeq ($(cc-name),clang) +KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) +KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) +KBUILD_CFLAGS += $(call cc-disable-warning, gnu) +# Quiet clang warning: comparison of unsigned expression < 0 is always false +KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) +# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the +# source of a reference will be _MergedGlobals and not on of the whitelisted names. +# See modpost pattern 2 +KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) +KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) +else + +# These warnings generated too much noise in a regular build. +# Use make W=1 to enable them (see scripts/Makefile.build) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) +endif + +ifdef CONFIG_FRAME_POINTER +KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else +# Some targets (ARM with Thumb2, for example), can't be built with frame +# pointers. For those, we don't have FUNCTION_TRACER automatically +# select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is +# incompatible with -fomit-frame-pointer with current GCC, so we don't use +# -fomit-frame-pointer with FUNCTION_TRACER. +ifndef CONFIG_FUNCTION_TRACER +KBUILD_CFLAGS += -fomit-frame-pointer +endif +endif + +KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) + +ifdef CONFIG_DEBUG_INFO +ifdef CONFIG_DEBUG_INFO_SPLIT +KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) +else +KBUILD_CFLAGS += -g +endif +KBUILD_AFLAGS += -Wa,-gdwarf-2 +endif +ifdef CONFIG_DEBUG_INFO_DWARF4 +KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) +endif + +ifdef CONFIG_DEBUG_INFO_REDUCED +KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ + $(call cc-option,-fno-var-tracking) +endif + +ifdef CONFIG_FUNCTION_TRACER +ifndef CC_FLAGS_FTRACE +CC_FLAGS_FTRACE := -pg +endif +export CC_FLAGS_FTRACE +ifdef CONFIG_HAVE_FENTRY +CC_USING_FENTRY := $(call cc-option, -mfentry -DCC_USING_FENTRY) +endif +KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_USING_FENTRY) +KBUILD_AFLAGS += $(CC_USING_FENTRY) +ifdef CONFIG_DYNAMIC_FTRACE + ifdef CONFIG_HAVE_C_RECORDMCOUNT + BUILD_C_RECORDMCOUNT := y + export BUILD_C_RECORDMCOUNT + endif +endif +endif + +# We trigger additional mismatches with less inlining +ifdef CONFIG_DEBUG_SECTION_MISMATCH +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) +endif + +# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +CHECKFLAGS += $(NOSTDINC_FLAGS) + +# warn about C99 declaration after statement +KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) + +# disable pointer signed / unsigned warnings in gcc 4.0 +KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) + +# disable invalid "can't wrap" optimizations for signed / pointers +KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) + +# conserve stack if available +KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) + +# disallow errors like 'EXPORT_GPL(foo);' with missing header +KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int) + +# require functions to have arguments in prototypes, not empty 'int foo()' +KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes) + +# Prohibit date/time macros, which would make the build non-deterministic +KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) + +# enforce correct pointer usage +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) + +# use the deterministic mode of AR if available +KBUILD_ARFLAGS := $(call ar-option,D) + +include scripts/Makefile.kasan +include scripts/Makefile.extrawarn +include scripts/Makefile.ubsan + +# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the +# last assignments +KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) +KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) +KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) + +# Use --build-id when available. +LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ + $(call cc-ldoption, -Wl$(comma)--build-id,)) +KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) +LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) + +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +LDFLAGS_vmlinux += $(call ld-option, --gc-sections,) +endif + +ifeq ($(CONFIG_STRIP_ASM_SYMS),y) +LDFLAGS_vmlinux += $(call ld-option, -X,) +endif + +# Default kernel image to build when no specific target is given. +# KBUILD_IMAGE may be overruled on the command line or +# set in the environment +# Also any assignments in arch/$(ARCH)/Makefile take precedence over +# this default value +export KBUILD_IMAGE ?= vmlinux + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?= /boot + +# +# INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots. +# Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as +# an argument if needed. Otherwise it defaults to the kernel install path +# +export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) + +# +# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory +# relocations required by build roots. This is not defined in the +# makefile but the argument can be passed to make if needed. +# + +MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +export MODLIB + +# +# INSTALL_MOD_STRIP, if defined, will cause modules to be +# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then +# the default option --strip-debug will be used. Otherwise, +# INSTALL_MOD_STRIP value will be used as the options to the strip command. + +ifdef INSTALL_MOD_STRIP +ifeq ($(INSTALL_MOD_STRIP),1) +mod_strip_cmd = $(STRIP) --strip-debug +else +mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) +endif # INSTALL_MOD_STRIP=1 +else +mod_strip_cmd = true +endif # INSTALL_MOD_STRIP +export mod_strip_cmd + +# CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed +# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP +# or CONFIG_MODULE_COMPRESS_XZ. + +mod_compress_cmd = true +ifdef CONFIG_MODULE_COMPRESS + ifdef CONFIG_MODULE_COMPRESS_GZIP + mod_compress_cmd = gzip -n -f + endif # CONFIG_MODULE_COMPRESS_GZIP + ifdef CONFIG_MODULE_COMPRESS_XZ + mod_compress_cmd = xz -f + endif # CONFIG_MODULE_COMPRESS_XZ +endif # CONFIG_MODULE_COMPRESS +export mod_compress_cmd + +# Select initial ramdisk compression format, default is gzip(1). +# This shall be used by the dracut(8) tool while creating an initramfs image. +# +INITRD_COMPRESS-y := gzip +INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2 +INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma +INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz +INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo +INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4 +# do not export INITRD_COMPRESS, since we didn't actually +# choose a sane default compression above. +# export INITRD_COMPRESS := $(INITRD_COMPRESS-y) + +ifdef CONFIG_MODULE_SIG_ALL +$(eval $(call config_filename,MODULE_SIG_KEY)) + +mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 +else +mod_sign_cmd = true +endif +export mod_sign_cmd + +ifdef CONFIG_STACK_VALIDATION + has_libelf := $(call try-run,\ + echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0) + ifeq ($(has_libelf),1) + objtool_target := tools/objtool FORCE + else + $(warning "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel") + SKIP_STACK_VALIDATION := 1 + export SKIP_STACK_VALIDATION + endif +endif + + +ifeq ($(KBUILD_EXTMOD),) +core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ + +vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) + +vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ + $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-)))) + +init-y := $(patsubst %/, %/built-in.o, $(init-y)) +core-y := $(patsubst %/, %/built-in.o, $(core-y)) +drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) +net-y := $(patsubst %/, %/built-in.o, $(net-y)) +libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) +libs-y := $(libs-y1) $(libs-y2) +virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) + +# Externally visible symbols (used by link-vmlinux.sh) +export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) +export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(virt-y) +export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds +export LDFLAGS_vmlinux +# used by scripts/pacmage/Makefile +export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) + +vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) + +# Include targets which we want to execute sequentially if the rest of the +# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be +# evaluated more than once. +PHONY += vmlinux_prereq +vmlinux_prereq: $(vmlinux-deps) FORCE +ifdef CONFIG_HEADERS_CHECK + $(Q)$(MAKE) -f $(srctree)/Makefile headers_check +endif +ifdef CONFIG_GDB_SCRIPTS + $(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py +endif +ifdef CONFIG_TRIM_UNUSED_KSYMS + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ + "$(MAKE) -f $(srctree)/Makefile vmlinux" +endif + +# standalone target for easier testing +include/generated/autoksyms.h: FORCE + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh true + +ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) + +# Final link of vmlinux with optional arch pass after final link + cmd_link-vmlinux = \ + $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) + +vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE + +$(call if_changed,link-vmlinux) + +# Build samples along the rest of the kernel +ifdef CONFIG_SAMPLES +vmlinux-dirs += samples +endif + +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; + +# Handle descending into subdirectories listed in $(vmlinux-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language + +PHONY += $(vmlinux-dirs) +$(vmlinux-dirs): prepare scripts + $(Q)$(MAKE) $(build)=$@ + +define filechk_kernel.release + echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" +endef + +# Store (new) KERNELRELEASE string in include/config/kernel.release +include/config/kernel.release: include/config/auto.conf FORCE + $(call filechk,kernel.release) + + +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +# Listed in dependency order +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 + +# prepare3 is used to check if we are building in a separate output directory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +prepare3: include/config/kernel.release +ifneq ($(KBUILD_SRC),) + @$(kecho) ' Using $(srctree) as source for kernel' + $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ + echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ + echo >&2 " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; +endif + +# prepare2 creates a makefile if using a separate output directory. +# From this point forward, .config has been reprocessed, so any rules +# that need to depend on updated CONFIG_* values can be checked here. +prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic + +prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ + include/config/auto.conf + $(cmd_crmodverdir) + +archprepare: archheaders archscripts prepare1 scripts_basic + +prepare0: archprepare gcc-plugins + $(Q)$(MAKE) $(build)=. + +# All the preparing.. +prepare: prepare0 prepare-objtool + +PHONY += prepare-objtool +prepare-objtool: $(objtool_target) + +# Check for CONFIG flags that require compiler support. Abort the build +# after .config has been processed, but before the kernel build starts. +# +# For security-sensitive CONFIG options, we don't want to fallback and/or +# silently change which compiler flags will be used, since that leads to +# producing kernels with different security feature characteristics +# depending on the compiler used. (For example, "But I selected +# CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!") +PHONY += prepare-compiler-check +prepare-compiler-check: FORCE +# Make sure compiler supports requested stack protector flag. +ifdef stackp-name + ifeq ($(call cc-option, $(stackp-flag)),) + @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \ + $(stackp-flag) not supported by compiler >&2 && exit 1 + endif +endif +# Make sure compiler does not have buggy stack-protector support. +ifdef stackp-check + ifneq ($(shell $(CONFIG_SHELL) $(stackp-check) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y) + @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \ + $(stackp-flag) available but compiler is broken >&2 && exit 1 + endif +endif + @: + +# Generate some files +# --------------------------------------------------------------------------- + +# KERNELRELEASE can change from a few different places, meaning version.h +# needs to be updated, so this check is forced on all builds + +uts_len := 64 +define filechk_utsrelease.h + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ + exit 1; \ + fi; \ + (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";) +endef + +define filechk_version.h + (echo \#define LINUX_VERSION_CODE $(shell \ + expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) +endef + +$(version_h): $(srctree)/Makefile FORCE + $(call filechk,version.h) + $(Q)rm -f $(old_version_h) + +include/generated/utsrelease.h: include/config/kernel.release FORCE + $(call filechk,utsrelease.h) + +PHONY += headerdep +headerdep: + $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ + $(srctree)/scripts/headerdep.pl -I$(srctree)/include + +# --------------------------------------------------------------------------- +# Firmware install +INSTALL_FW_PATH=$(INSTALL_MOD_PATH)/lib/firmware +export INSTALL_FW_PATH + +PHONY += firmware_install +firmware_install: + @mkdir -p $(objtree)/firmware + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install + +# --------------------------------------------------------------------------- +# Kernel headers + +#Default location for installed headers +export INSTALL_HDR_PATH = $(objtree)/usr + +# If we do an all arch process set dst to asm-$(hdr-arch) +hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm) + +PHONY += archheaders +archheaders: + +PHONY += archscripts +archscripts: + +PHONY += __headers +__headers: $(version_h) scripts_basic asm-generic archheaders archscripts + $(Q)$(MAKE) $(build)=scripts build_unifdef + +PHONY += headers_install_all +headers_install_all: + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install + +PHONY += headers_install +headers_install: __headers + $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/uapi/asm/Kbuild),, \ + $(error Headers not exportable for the $(SRCARCH) architecture)) + $(Q)$(MAKE) $(hdr-inst)=include/uapi + $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) + +PHONY += headers_check_all +headers_check_all: headers_install_all + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check + +PHONY += headers_check +headers_check: headers_install + $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1 + $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1 + +# --------------------------------------------------------------------------- +# Kernel selftest + +PHONY += kselftest +kselftest: + $(Q)$(MAKE) -C tools/testing/selftests run_tests + +kselftest-clean: + $(Q)$(MAKE) -C tools/testing/selftests clean + +PHONY += kselftest-merge +kselftest-merge: + $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ + -m $(objtree)/.config \ + $(srctree)/tools/testing/selftests/*/config + +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig + +# --------------------------------------------------------------------------- +# Modules + +ifdef CONFIG_MODULES + +# By default, build modules as well + +all: modules + +# Build modules +# +# A module can be listed more than once in obj-m resulting in +# duplicate lines in modules.order files. Those are removed +# using awk while concatenating to the final file. + +PHONY += modules +modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin + $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order + @$(kecho) ' Building modules, stage 2.'; + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild + +modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) + $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin + +%/modules.builtin: include/config/auto.conf + $(Q)$(MAKE) $(modbuiltin)=$* + + +# Target to prepare building external modules +PHONY += modules_prepare +modules_prepare: prepare scripts + +# Target to install modules +PHONY += modules_install +modules_install: _modinst_ _modinst_post + +PHONY += _modinst_ +_modinst_: + @rm -rf $(MODLIB)/kernel + @rm -f $(MODLIB)/source + @mkdir -p $(MODLIB)/kernel + @ln -s `cd $(srctree) && /bin/pwd` $(MODLIB)/source + @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ + rm -f $(MODLIB)/build ; \ + ln -s $(CURDIR) $(MODLIB)/build ; \ + fi + @cp -f $(objtree)/modules.order $(MODLIB)/ + @cp -f $(objtree)/modules.builtin $(MODLIB)/ + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + +# This depmod is only for convenience to give the initial +# boot a modules.dep even before / is mounted read-write. However the +# boot script depmod is the master version. +PHONY += _modinst_post +_modinst_post: _modinst_ + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modinst + $(call cmd,depmod) + +ifeq ($(CONFIG_MODULE_SIG), y) +PHONY += modules_sign +modules_sign: + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign +endif + +else # CONFIG_MODULES + +# Modules not configured +# --------------------------------------------------------------------------- + +PHONY += modules modules_install +modules modules_install: + @echo >&2 + @echo >&2 "The present kernel configuration has modules disabled." + @echo >&2 "Type 'make config' and enable loadable module support." + @echo >&2 "Then build a kernel with module support enabled." + @echo >&2 + @exit 1 + +endif # CONFIG_MODULES + +### +# Cleaning is done on three levels. +# make clean Delete most generated files +# Leave enough to build external modules +# make mrproper Delete the current configuration, and all generated files +# make distclean Remove editor backup files, patch leftover files and the like + +# Directories & files removed with 'make clean' +CLEAN_DIRS += $(MODVERDIR) + +# Directories & files removed with 'make mrproper' +MRPROPER_DIRS += include/config usr/include include/generated \ + arch/*/include/generated .tmp_objdiff +MRPROPER_FILES += .config .config.old .version .old_version \ + Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ + signing_key.pem signing_key.priv signing_key.x509 \ + x509.genkey extra_certificates signing_key.x509.keyid \ + signing_key.x509.signer vmlinux-gdb.py + +# clean - Delete most, but leave enough to build external modules +# +clean: rm-dirs := $(CLEAN_DIRS) +clean: rm-files := $(CLEAN_FILES) +clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples) + +PHONY += $(clean-dirs) clean archclean vmlinuxclean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +vmlinuxclean: + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean + $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) + +clean: archclean vmlinuxclean + +# mrproper - Delete all generated files, including .config +# +mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) +mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) +mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) + +PHONY += $(mrproper-dirs) mrproper archmrproper +$(mrproper-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) + +mrproper: clean archmrproper $(mrproper-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + +# distclean +# +PHONY += distclean + +distclean: mrproper + @find $(srctree) $(RCS_FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \ + -type f -print | xargs rm -f + + +# Packaging of the kernel to various formats +# --------------------------------------------------------------------------- +# rpm target kept for backward compatibility +package-dir := scripts/package + +%src-pkg: FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ +%pkg: include/config/kernel.release FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ +rpm: include/config/kernel.release FORCE + $(Q)$(MAKE) $(build)=$(package-dir) $@ + + +# Brief documentation of the typical targets used +# --------------------------------------------------------------------------- + +boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) +boards := $(sort $(notdir $(boards))) +board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) +board-dirs := $(sort $(notdir $(board-dirs:/=))) + +PHONY += help +help: + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files but keep the config and' + @echo ' enough build support to build external modules' + @echo ' mrproper - Remove all generated files + config + various backup files' + @echo ' distclean - mrproper + remove editor backup and patch files' + @echo '' + @echo 'Configuration targets:' + @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help + @echo '' + @echo 'Other generic targets:' + @echo ' all - Build all targets marked with [*]' + @echo '* vmlinux - Build the bare kernel' + @echo '* modules - Build all modules' + @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' + @echo ' firmware_install- Install all firmware to INSTALL_FW_PATH' + @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)' + @echo ' dir/ - Build all files in dir and below' + @echo ' dir/file.[ois] - Build specified target only' + @echo ' dir/file.lst - Build specified mixed source/assembly target only' + @echo ' (requires a recent binutils and recent build (System.map))' + @echo ' dir/file.ko - Build module including final link' + @echo ' modules_prepare - Set up for building external modules' + @echo ' tags/TAGS - Generate tags file for editors' + @echo ' cscope - Generate cscope index' + @echo ' gtags - Generate GNU GLOBAL index' + @echo ' kernelrelease - Output the release version string (use with make -s)' + @echo ' kernelversion - Output the version stored in Makefile (use with make -s)' + @echo ' image_name - Output the image name (use with make -s)' + @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ + echo ' (default: $(INSTALL_HDR_PATH))'; \ + echo '' + @echo 'Static analysers' + @echo ' checkstack - Generate a list of stack hogs' + @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' + @echo ' includecheck - Check for duplicate included header files' + @echo ' export_report - List the usages of all exported symbols' + @echo ' headers_check - Sanity check on exported headers' + @echo ' headerdep - Detect inclusion cycles in headers' + @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help + @echo '' + @echo 'Kernel selftest' + @echo ' kselftest - Build and run kernel selftest (run as root)' + @echo ' Build, install, and boot kernel before' + @echo ' running kselftest on it' + @echo ' kselftest-clean - Remove all generated kselftest files' + @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existed' + @echo ' .config.' + @echo '' + @echo 'Kernel packaging:' + @$(MAKE) $(build)=$(package-dir) help + @echo '' + @echo 'Documentation targets:' + @$(MAKE) -f $(srctree)/Documentation/Makefile.sphinx dochelp + @echo '' + @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp + @echo '' + @echo 'Architecture specific targets ($(SRCARCH)):' + @$(if $(archhelp),$(archhelp),\ + echo ' No architecture specific help defined for $(SRCARCH)') + @echo '' + @$(if $(boards), \ + $(foreach b, $(boards), \ + printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ + echo '') + @$(if $(board-dirs), \ + $(foreach b, $(board-dirs), \ + printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ + printf " %-16s - Show all of the above\\n" help-boards; \ + echo '') + + @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' + @echo ' make V=2 [targets] 2 => give reason for rebuild of target' + @echo ' make O=dir [targets] Locate all output files in "dir", including .config' + @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' + @echo ' make C=2 [targets] Force check of all c source with $$CHECK' + @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' + @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' + @echo ' 1: warnings which may be relevant and do not occur too often' + @echo ' 2: warnings which occur quite often but may still be relevant' + @echo ' 3: more obscure warnings, can most likely be ignored' + @echo ' Multiple levels can be combined with W=12 or W=123' + @echo '' + @echo 'Execute "make" or "make all" to build all targets marked with [*] ' + @echo 'For further info see the ./README file' + + +help-board-dirs := $(addprefix help-,$(board-dirs)) + +help-boards: $(help-board-dirs) + +boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig))) + +$(help-board-dirs): help-%: + @echo 'Architecture specific targets ($(SRCARCH) $*):' + @$(if $(boards-per-dir), \ + $(foreach b, $(boards-per-dir), \ + printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ + echo '') + + +# Documentation targets +# --------------------------------------------------------------------------- +DOC_TARGETS := xmldocs sgmldocs psdocs latexdocs pdfdocs htmldocs mandocs installmandocs epubdocs cleandocs linkcheckdocs +PHONY += $(DOC_TARGETS) +$(DOC_TARGETS): scripts_basic FORCE + $(Q)$(MAKE) $(build)=scripts build_docproc build_check-lc_ctype + $(Q)$(MAKE) $(build)=Documentation -f $(srctree)/Documentation/Makefile.sphinx $@ + $(Q)$(MAKE) $(build)=Documentation/DocBook $@ + +else # KBUILD_EXTMOD + +### +# External module support. +# When building external modules the kernel used as basis is considered +# read-only, and no consistency checks are made and the make +# system is not used on the basis kernel. If updates are required +# in the basis kernel ordinary make commands (without M=...) must +# be used. +# +# The following are the only valid targets when building external +# modules. +# make M=dir clean Delete all automatically generated files +# make M=dir modules Make all modules in specified dir +# make M=dir Same as 'make M=dir modules' +# make M=dir modules_install +# Install the modules built in the module directory +# Assumes install directory is already created + +# We are always building modules +KBUILD_MODULES := 1 +PHONY += crmodverdir +crmodverdir: + $(cmd_crmodverdir) + +PHONY += $(objtree)/Module.symvers +$(objtree)/Module.symvers: + @test -e $(objtree)/Module.symvers || ( \ + echo; \ + echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ + echo " is missing; modules will have no dependencies and modversions."; \ + echo ) + +module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) +PHONY += $(module-dirs) modules +$(module-dirs): crmodverdir $(objtree)/Module.symvers + $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) + +modules: $(module-dirs) + @$(kecho) ' Building modules, stage 2.'; + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +PHONY += modules_install +modules_install: _emodinst_ _emodinst_post + +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +PHONY += _emodinst_ +_emodinst_: + $(Q)mkdir -p $(MODLIB)/$(install-dir) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + +PHONY += _emodinst_post +_emodinst_post: _emodinst_ + $(call cmd,depmod) + +clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) + +PHONY += $(clean-dirs) clean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: rm-dirs := $(MODVERDIR) +clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers + +PHONY += help +help: + @echo ' Building external modules.' + @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' + @echo '' + @echo ' modules - default target, build the module(s)' + @echo ' modules_install - install the module' + @echo ' clean - remove generated files in module directory only' + @echo '' + +# Dummies... +PHONY += prepare scripts +prepare: ; +scripts: ; +endif # KBUILD_EXTMOD + +clean: $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '*.ko.*' \ + -o -name '*.dwo' \ + -o -name '*.su' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '*.symtypes' -o -name 'modules.order' \ + -o -name modules.builtin -o -name '.tmp_*.o.*' \ + -o -name '*.c.[012]*.*' \ + -o -name '*.gcno' \) -type f -print | xargs rm -f + +# Generate tags for editors +# --------------------------------------------------------------------------- +quiet_cmd_tags = GEN $@ + cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ + +tags TAGS cscope gtags: FORCE + $(call cmd,tags) + +# Scripts to check various things for consistency +# --------------------------------------------------------------------------- + +PHONY += includecheck versioncheck coccicheck namespacecheck export_report + +includecheck: + find $(srctree)/* $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl + +versioncheck: + find $(srctree)/* $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl + +coccicheck: + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ + +namespacecheck: + $(PERL) $(srctree)/scripts/namespace.pl + +export_report: + $(PERL) $(srctree)/scripts/export_report.pl + +endif #ifeq ($(config-targets),1) +endif #ifeq ($(mixed-targets),1) + +PHONY += checkstack kernelrelease kernelversion image_name + +# UML needs a little special treatment here. It wants to use the host +# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone +# else wants $(ARCH), including people doing cross-builds, which means +# that $(SUBARCH) doesn't work here. +ifeq ($(ARCH), um) +CHECKSTACK_ARCH := $(SUBARCH) +else +CHECKSTACK_ARCH := $(ARCH) +endif +checkstack: + $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ + $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) + +kernelrelease: + @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" + +kernelversion: + @echo $(KERNELVERSION) + +image_name: + @echo $(KBUILD_IMAGE) + +# Clear a bunch of variables before executing the submake +tools/: FORCE + $(Q)mkdir -p $(objtree)/tools + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ + +tools/%: FORCE + $(Q)mkdir -p $(objtree)/tools + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $* + +# Single targets +# --------------------------------------------------------------------------- +# Single targets are compatible with: +# - build with mixed source and output +# - build with separate output dir 'make O=...' +# - external modules +# +# target-dir => where to store outputfile +# build-dir => directory in kernel source tree to use + +ifeq ($(KBUILD_EXTMOD),) + build-dir = $(patsubst %/,%,$(dir $@)) + target-dir = $(dir $@) +else + zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) + build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) + target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) +endif + +%.s: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.i: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.lst: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.s: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.o: %.S prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.symtypes: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) + +# Modules +/: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) +# Make sure the latest headers are built for Documentation +Documentation/ samples/: headers_install +%/: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) +%.ko: prepare scripts FORCE + $(cmd_crmodverdir) + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(build-dir) $(@:.ko=.o) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +# FIXME Should go into a make.lib or something +# =========================================================================== + +quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) + cmd_rmdirs = rm -rf $(rm-dirs) + +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) + +# Run depmod only if we have System.map and depmod is executable +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))" + +# Create temporary dir for module support files +# clean it up only when building all modules +cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ + $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) + +# read all saved command lines + +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) + +ifneq ($(cmd_files),) + $(cmd_files): ; # Do not try to update included dependency files + include $(cmd_files) +endif + +endif # skip-makefile + +PHONY += FORCE +FORCE: + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable so we can use it in if_changed and friends. +.PHONY: $(PHONY) diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_03/README.md b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_03/README.md new file mode 100644 index 0000000..05c50b3 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/kiwiz/task_03/README.md @@ -0,0 +1,4 @@ +Steps +===== + +- `git format-patch -o /tmp/ HEAD~` diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/useful_scripts/sending_mutt.sh b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/useful_scripts/sending_mutt.sh new file mode 100644 index 0000000..71f9435 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/eudyptula-challenge-solutions/useful_scripts/sending_mutt.sh @@ -0,0 +1 @@ +mutt -s [7e1cf379bd3d] Task 01 of the Eudyptula Challenge little@eudyptula-challenge.org -a ~/Projects/eudyptula-challenge/task_01/eudyptula_1.c diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/clean_bit.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/clean_bit.py new file mode 100644 index 0000000..6222c15 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/clean_bit.py @@ -0,0 +1,35 @@ +#!/usr/bin/python + +''' Clear a bit in a binary number. + Like the reverse of set bit: + 1) first create a number filled of 1s, + with 0 at i (can create 0001000 and ~) + 2) AND the number so it clears the ith bit +''' + + + +def clear_bit(num, i): + mask = ~ (1 << i) # -0b10001 + return bin(num & mask) + + +def clear_all_bits_from_i_to_0(num, i): + mask = ~ ( (1 << (i+1)) - 1) + return bin(num & mask) + + +def clear_all_bits_from_most_sig_to_1(num, i): + mask = ( 1 << i) -1 + return bin(num & mask) + + +if __name__ == '__main__': + num = int('10010000', 2) + print clear_bit(num, 4) # '0b10000000' + + num = int('10010011', 2) + print clear_all_bits_from_i_to_0(num, 2) # '0b10010000' + + num = int('1110011', 2) + print clear_all_bits_from_most_sig_to_1(num, 2) #'0b11' \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/count_bits.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/count_bits.py new file mode 100644 index 0000000..596c5cd --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/count_bits.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +''' This method returns the number of bits that are necessary to change to convert two + numbers A and B: + 1) XOR + 2) count 1s +''' + +def count_bits_swap2(a, b): + count = 0 + m = a^b + while m: + count +=1 + m = m & (m-1) + return count + + + +def count_bits_swap(a, b): + m = a^b + return count_1s(m) + + +def count_1s(m): + count = 0 + while m: + if m& 1 : + count +=1 + m >>= 1 + return count + + +if __name__ == '__main__': + a = int('10010000', 2) + b = int('01011010', 2) + print count_bits_swap(a, b) #4 + print count_bits_swap2(a, b) #4 \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/get_bit.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/get_bit.py new file mode 100644 index 0000000..ab768ae --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/get_bit.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +''' Set a bit in a binary number: + 1) Shifts 1 over by i bits + 2) make an OR with the number, only the value at bit i will change and all the others bit + of the mask are zero so will not affect the num + +''' +def set_bit(num, i): + mask = 1 << i + return bin( num | mask ) + + +if __name__ == '__main__': + num = int('0100100', 2) + print set_bit(num, 0) #'0b100101' + print set_bit(num, 1) #'0b100110' + print set_bit(num, 2) # nothing change '0b100100' + print set_bit(num, 3) #'0b101100' + print set_bit(num, 4) #'0b110100' + print set_bit(num, 5) # nothing change '0b100100' \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/update_bit.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/update_bit.py new file mode 100644 index 0000000..78e1413 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/bitwise_stuff/update_bit.py @@ -0,0 +1,19 @@ +#!/usr/bin/python + +''' This method merges set bit and clean bit: + 1) first clear the bit at i using a mask such as 1110111 + 2) then shift the intended value v by i bits + 3) this will create a number with bit i to v and all other to 0 + 4) finally update the ith bit with or +''' + + + +def update_bit(num, i, v): + mask = ~ (1 << i) + return bin( (num & mask) | (v << i) ) + + +if __name__ == '__main__': + num = int('10010000', 2) + print update_bit(num, 2, 1) # '0b10010100' \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/angry_bird.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/angry_bird.py new file mode 100644 index 0000000..13959f5 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/angry_bird.py @@ -0,0 +1,37 @@ +#!/bin/python + +""" +Each round, players receive a score between 0 and 100, which you use to rank them from highest to lowest. So far you're using an algorithm that sorts in O(n\lg{n})O(nlgn) time, but players are complaining that their rankings aren't updated fast enough. You need a faster sorting algorithm. + +Write a function that takes: + +a list of unsorted_scores +the highest_possible_score in the game +and returns a sorted list of scores in less than O(n\lg{n})O(nlgn) time. +""" + +def sort_scores(unsorted_scores, highest_score): + + score_counts = [0] * (highest_score+1) + + for score in unsorted_scores: + score_counts[score] += 1 + + sorted_scores = [] + + for score in range(len(score_counts)-1, -1, -1): + count = score_counts[score] + + for i in range(count): + sorted_scores.append(score) + + return sorted_scores + + + +if __name__ == '__main__': + + unsorted_scores = [37, 89, 41, 65, 91, 53] + HIGHEST_POSSIBLE_SCORE = 100 + + print sort_scores(unsorted_scores, HIGHEST_POSSIBLE_SCORE) diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/file_system_hashing.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/file_system_hashing.py new file mode 100644 index 0000000..06c5e19 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/file_system_hashing.py @@ -0,0 +1,76 @@ +#!/bin/python + +""" +Write a function that returns a list of all the duplicate files. + +the first item is the duplicate file +the second item is the original file +For example: + + [('/tmp/parker_is_dumb.mpg', '/home/parker/secret_puppy_dance.mpg'), + ('/home/trololol.mov', '/etc/apache2/httpd.conf')] +You can assume each file was only duplicated once. +""" + +import os +import hashlib + +def find_duplicate_files(starting_directory): + files_seen_already = {} + stack = [starting_directory] + + duplicates = [] + + while len(stack): + current_path = stack.pop() + + if os.path.isdir(current_path): + for path in os.listdir(current_path): + full_path = os.path.join(current_path, path) + stack.append(full_path) + + else: + file_hash = sample_hash_file(current_path) + + current_last_edited_time = os.path.getmtime(current_path) + + if file_hash in files_seen_already: + existing_last_edited_time, existing_path = files_seen_already[file_hash] + if current_last_edited_time > existing_last_edited_time: + + duplicates.append((current_path, existing_path)) + else: + + duplicates.append((existing_path, current_path)) + files_seen_already[file_hash] = (current_last_edited_time, current_path) + + else: + files_seen_already[file_hash] = (current_last_edited_time, current_path) + + return duplicates + + +def sample_hash_file(path): + num_bytes_to_read_per_sample = 4000 + total_bytes = os.path.getsize(path) + hasher = hashlib.sha512() + + with open(path, 'rb') as file: + + if total_bytes < num_bytes_to_read_per_sample * 3: + hasher.update(file.read()) + else: + num_bytes_between_samples = ( + (total_bytes - num_bytes_to_read_per_sample * 3) / 2 + ) + + for offset_multiplier in range(3): + start_of_sample = ( + offset_multiplier + * (num_bytes_to_read_per_sample + num_bytes_between_samples) + ) + file.seek(start_of_sample) + sample = file.read(num_bytes_to_read_per_sample) + hasher.update(sample) + + return hasher.hexdigest() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/inflight_entrain.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/inflight_entrain.py new file mode 100644 index 0000000..6862d70 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/data_structures/inflight_entrain.py @@ -0,0 +1,42 @@ +#!/bin/python + +""" +Users on longer flights like to start a second movie right when their first one ends, +but they complain that the plane usually lands before they can see the ending. +So you're building a feature for choosing two movies whose total runtimes will equal the exact flight length. + +Write a function that takes an integer flight_length (in minutes) and a +list of integers movie_lengths (in minutes) and returns a boolean indicating +whether there are two numbers in movie_lengths whose sum equals flight_length. + +When building your function: + +Assume your users will watch exactly two movies +Don't make your users watch the same movie twice +Optimize for runtime over memory +""" + +def is_there_two_movies(flight_length, movie_lengths): + movie_lengths_seen = set() + + for first_movie_length in movie_lengths: + matching_second_movie_length = flight_length - first_movie_length + if matching_second_movie_length in movie_lengths_seen: + return True + movie_lengths_seen.add(first_movie_length) + + return False + + + +if __name__ == '__main__': + + flight_length = 10 + + movie_lengths = [2, 4, 7] + print(is_there_two_movies(flight_length, movie_lengths)) + print("Should be True") + + movie_lengths = [5, 6, 7, 8] + print(is_there_two_movies(flight_length, movie_lengths)) + print("Should be False") \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/apple_stocks.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/apple_stocks.py new file mode 100644 index 0000000..d4a5646 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/apple_stocks.py @@ -0,0 +1,27 @@ +#!/bin/python + +""" +Grab Apple's stock prices and put them in a list called stock_prices, where: + +The indices are the time (in minutes) past trade opening time, which was 9:30am local time. +The values are the price (in US dollars) of one share of Apple stock at that time. +So if the stock cost $500 at 10:30am, that means stock_prices[60] = 500. + +Write an efficient function that takes stock_prices and returns the best profit I could have made from one purchase and one sale of one share. +""" + +def apple_stock_profit(stock_prices): + + min_s, max_s = max(stock_prices), 0 + + while stock_prices: + stock = stock_prices.pop() + min_s = min(min_s, stock) + max_s = max(max_s, stock) + + return max_s - min_s + + +stock_prices = [10, 7, 5, 8, 11, 9] +print apple_stock_profit(stock_prices) +print("Should return 6 (buying for $5 and selling for $11)") \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/fib.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/fib.py new file mode 100644 index 0000000..8654152 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/fib.py @@ -0,0 +1,36 @@ +#!/bin/python + +""" +Write a function fib() that takes an integer nn and returns the nnth Fibonacci number. +""" + +# this is O(2^n) +def fib(n): + if n in [1, 0]: + return n + return fib(n - 1) + fib(n - 2) + + +print fib(10) + + +# this is O(n) +def fib(n): + if n < 0: + raise ValueError('Index was negative. No such thing as a ' + 'negative index in a series.') + elif n in [0, 1]: + return n + + prev_prev = 0 # 0th fibonacci + prev = 1 # 1st fibonacci + + for _ in range(n - 1): + current = prev + prev_prev + prev_prev = prev + prev = current + + return current + + +print fib(10) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/find_dup.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/find_dup.py new file mode 100644 index 0000000..7d2303f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/find_dup.py @@ -0,0 +1,38 @@ +#!/bin/python + +""" +Find a duplicate +We have a list of integers, where: +The integers are in the range 1..n1..n +The list has a length of n+1n+1 +It follows that our list has at least one integer which appears at least twice. But it may have several duplicates, and each duplicate may appear more than twice. + +Write a function which finds an integer that appears more than once in our list. (If there are multiple duplicates, you only need to find one of them.) +""" + +def find_dups(num_list): + num_dict = {} + for n in num_list: + if n in num_dict.keys(): + num_dict[n] += 1 + else: + num_dict[n] = 1 + + for k,v in num_dict.items(): + if v > 1: + print "dup is {}".format(k) + +def find_dups_set(num_list): + + num_set = set() + + for n in num_list: + if n in num_set: + print n + else: + num_set.add(n) + + +num_list = [6,1,3,7,6,4,5,2,8,5,6,6,7] +find_dups(num_list) +find_dups_set(num_list) diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/float_bin_num.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/float_bin_num.py new file mode 100644 index 0000000..3ca34ad --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/float_bin_num.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +''' Given a real number between 0 and 1 (eg: 0.72), this method print the binary + representation. If the Number cannot be represented accurately in binary, with at + most 32 chars, print error: +''' + +def get_float_rep(num): + if num >= 1 or num <= 0: return 'Error 1' + result = '.' + while num: + if len(result) >= 32: return 'Error 2', result + r = num*2 + if r >= 1: + result += '1' + num = r - 1 + else: + result += '0' + num = r + return result + + +if __name__ == '__main__': + print get_float_rep(0.72) #('Error 2', '.1011100001010001111010111000010') + print get_float_rep(0.1) # ('Error 2', '.0001100110011001100110011001100') + print get_float_rep(0.5) #'.1' \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/highest_product_3_int.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/highest_product_3_int.py new file mode 100644 index 0000000..ea2a401 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/highest_product_3_int.py @@ -0,0 +1,54 @@ +#!/bin/python + +""" +Given a list of integers, find the highest product you can get from three of the integers. + +The input list_of_ints will always have at least three integers. +""" + +def highest_num(list_of_ints): + + if len(list_of_ints) == 3: + return list_of_ints[0]*list_of_ints[1]*list_of_ints[2] + + sorted_list = sorted(list_of_ints) + + return sorted_list[-3]*sorted_list[-2]*sorted_list[-1] + + +def highest_product_of_3_On(list_of_ints): + + highest = max(list_of_ints[0], list_of_ints[1]) + lowest = min(list_of_ints[0], list_of_ints[1]) + highest_product_of_2 = list_of_ints[0] * list_of_ints[1] + lowest_product_of_2 = list_of_ints[0] * list_of_ints[1] + + highest_product_of_3 = list_of_ints[0] * list_of_ints[1] * list_of_ints[2] + + for i in range(2, len(list_of_ints)): + current = list_of_ints[i] + + highest_product_of_3 = max(highest_product_of_3, + current * highest_product_of_2, + current * lowest_product_of_2) + + highest_product_of_2 = max(highest_product_of_2, + current * highest, + current * lowest) + + lowest_product_of_2 = min(lowest_product_of_2, + current * highest, + current * lowest) + + highest = max(highest, current) + + lowest = min(lowest, current) + + return highest_product_of_3 + +list_of_ints = [4, 2, 5, 6] +print highest_num(list_of_ints) +print "Should be 120" + +print highest_product_of_3_On(list_of_ints) +print "Should be 120" \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/in_place_shuffle.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/in_place_shuffle.py new file mode 100644 index 0000000..850c48f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/in_place_shuffle.py @@ -0,0 +1,33 @@ +#!/bin/python + +""" +Write a function for doing an in-place shuffle of a list. + +The shuffle must be "uniform," meaning each item in the original list must have the same probability of ending up in each spot in the final list. + +Assume that you have a function get_random(floor, ceiling) for getting a random integer that is >= floor and <= ceiling. +""" + +import random + +def get_random(floor, ceiling): + return random.randrange(floor, ceiling + 1) + +def shuffle(the_list): + + if len(the_list) <= 1: + return the_list + + last_index_in_the_list = len(the_list) - 1 + + for i in range(len(the_list) - 1): + random_choice_index = get_random(i, + last_index_in_the_list) + if random_choice_index != i: + the_list[i], the_list[random_choice_index] = \ + the_list[random_choice_index], the_list[i] + + +seed_list = [5, 2, 6, 2, 6] +shuffle(seed_list) +print seed_list \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/product_every_int.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/product_every_int.py new file mode 100644 index 0000000..4c4fea9 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/product_every_int.py @@ -0,0 +1,38 @@ +#!/bin/python + +""" +You have a list of integers, and for each index you want to find the product of every integer except the integer at that index. + +Write a function get_products_of_all_ints_except_at_index() that takes a list of integers and returns a list of the products. + +For example, given: + + [1, 7, 3, 4] + +your function would return: + + [84, 12, 28, 21] + +by calculating: + + [7 * 3 * 4, 1 * 3 * 4, 1 * 7 * 4, 1 * 7 * 3] + +Here's the catch: You can't use division in your solution! +""" + +def get_products_of_all_ints_except_at_index(array): + prod_array = [] + + for i, num in enumerate(array): + prod = 1 + for other_num in array[:i] + array[i+1:]: + prod *= other_num + + prod_array.append(prod) + + return prod_array + + +array = [1, 7, 3, 4] +print get_products_of_all_ints_except_at_index(array) +print "Should be [84, 12, 28, 21]" \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/recursive_per.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/recursive_per.py new file mode 100644 index 0000000..0c9d00f --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/math/recursive_per.py @@ -0,0 +1,32 @@ +#!/bin/python + +""" +Write a recursive function for generating all permutations of an input string. Return them as a set. +""" + +def get_permutations(string): + + if len(string) < 2: + return set([string]) + + all_chars_except_last = string[:-1] + last_char = string[-1] + + permutations_of_all_chars_except_last = get_permutations(all_chars_except_last) + + permutations = set() + for permutation_of_all_chars_except_last in permutations_of_all_chars_except_last: + for position in range(len(all_chars_except_last) + 1): + permutation = ( + permutation_of_all_chars_except_last[:position] + + last_char + + permutation_of_all_chars_except_last[position:] + ) + permutations.add(permutation) + + + return permutations + + +str = "abcd" +print get_permutations(str) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/big_words.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/big_words.py new file mode 100644 index 0000000..dde0af3 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/big_words.py @@ -0,0 +1,70 @@ +#!/bin/python + +""" +I want to learn some big words so people think I'm smart. + +I opened up a dictionary to a page in the middle and started flipping through, looking for words I didn't know. I put each word I didn't know at increasing indices in a huge list I created in memory. When I reached the end of the dictionary, I started from the beginning and did the same thing until I reached the page I started at. + +Now I have a list of words that are mostly alphabetical, except they start somewhere in the middle of the alphabet, reach the end, and then start from the beginning of the alphabet. In other words, this is an alphabetically ordered list that has been "rotated." For example: + + words = [ + 'ptolemaic', + 'retrograde', + 'supplant', + 'undulate', + 'xenoepist', + 'asymptote', # <-- rotates here! + 'babka', + 'banoffee', + 'engender', + 'karpatka', + 'othellolagkage', +] + +Write a function for finding the index of the "rotation point," which is where I started working from the beginning of the dictionary. This list is huge (there are lots of words I don't know) so we want to be efficient here. +""" + +def find_index(words): + + for i, word in enumerate(words): + if word[0] > words[i+1][0]: + return i+1, words[i+1] + + return "Not found" + + + +def find_index_bs(words): + first_word = words[0] + floor_index = 0 + ceiling_index = len(words) - 1 + + while floor_index < ceiling_index: + guess_index = floor_index + ((ceiling_index - floor_index) / 2) + + if words[guess_index] >= first_word: + floor_index = guess_index + else: + ceiling_index = guess_index + + if floor_index + 1 == ceiling_index: + return ceiling_index + + +words = [ + 'ptolemaic', + 'retrograde', + 'supplant', + 'undulate', + 'xenoepist', + 'asymptote', + 'babka', + 'banoffee', + 'engender', + 'karpatka', + 'othellolagkage', +] + +print find_index(words) +print +print find_index_bs(words) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/binary_search.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/binary_search.py new file mode 100644 index 0000000..6d15053 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/binary_search.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + + +def binary_search(array, value): + last, first = len(array), 0 + + while first < last: + mid = (last - first)//2 + item = array[mid] + + if item == value: + return True + + elif item < value: + last = mid + + else: + first = mid + + return False + +def binary_search_rec(array, value, first=0, last=None): + last = last or len(array) + if len(array[first:last]) < 1: + return False + + mid = (last - first)//2 + if array[mid] == value: + return True + elif array[mid] < value: + return binary_search_rec(array, value, first=first, last=mid) + else: + return binary_search_rec(array, value, first=mid, last=last) + + +array = [3, 4, 6, 7, 10, 11, 34, 67, 84] +value = 6 +assert(binary_search(array, value) == True) +assert(binary_search_rec(array, value) == True) +value = 8 +assert(binary_search(array, value) == False) +assert(binary_search_rec(array, value) == False) +array = [8] +assert(binary_search(array, value) == True) +assert(binary_search_rec(array, value) == True) +array = [] +assert(binary_search(array, value) == False) +assert(binary_search_rec(array, value) == False) diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/merge_sort.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/merge_sort.py new file mode 100644 index 0000000..8560722 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/merge_sort.py @@ -0,0 +1,37 @@ + #!/usr/bin/env python + +def merge_sort(list_to_sort): + # Base case: lists with fewer than 2 elements are sorted + if len(list_to_sort) < 2: + return list_to_sort + + # Step 1: divide the list in half + mid_index = len(list_to_sort) / 2 + left = list_to_sort[:mid_index] + right = list_to_sort[mid_index:] + + # Step 2: sort each half + sorted_left = merge_sort(left) + sorted_right = merge_sort(right) + + # Step 3: merge the sorted halves + sorted_list = [] + current_index_left = 0 + current_index_right = 0 + + while len(sorted_list) < len(left) + len(right): + if ((current_index_left < len(left)) and + (current_index_right == len(right) or + sorted_left[current_index_left] < sorted_right[current_index_right])): + sorted_list.append(sorted_left[current_index_left]) + current_index_left += 1 + else: + sorted_list.append(sorted_right[current_index_right]) + current_index_right += 1 + return sorted_list + + + +list_to_sort = [5, 3, 7, 12, 1, 0, 10] + +print merge_sort(list_to_sort) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/merge_sorted_list.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/merge_sorted_list.py new file mode 100644 index 0000000..2c9aeb0 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/sort_and_search/merge_sorted_list.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +""" +In order to win the prize for most cookies sold, my friend Alice and +# I are going to merge our Girl Scout Cookies orders and enter as one unit. +# Each order is represented by an "order id" (an integer). +We have our lists of orders sorted numerically already, in lists. +Write a function to merge our lists of orders into one sorted list. +""" + +def merge_lists(my_list, alices_list): + + result = [] + index_alice_list = 0 + index_my_list = 0 + + while index_alice_list < len(alices_list) and index_my_list < len(my_list): + if alices_list[index_alice_list] < my_list[index_my_list]: + result.append(alices_list[index_alice_list]) + index_alice_list += 1 + elif alices_list[index_alice_list] > my_list[index_my_list]: + result.append(my_list[index_my_list]) + index_my_list += 1 + else: + result.append(my_list[index_my_list]) + result.append(alices_list[index_alice_list]) + index_my_list += 1 + index_alice_list += 1 + + if index_alice_list < len(alices_list): + result.extend(alices_list[index_alice_list:]) + + if index_my_list < len(my_list): + result.extend(my_list[index_my_list:]) + + return result + + +my_list = [3, 4, 6, 10, 11, 15] +alices_list = [1, 5, 8, 12, 14, 19] + + +print merge_lists(my_list, alices_list) +print "Must be [1, 3, 4, 5, 6, 8, 10, 11, 12, 14, 15, 19]" + + +# Or just using Timsort +def merge_sorted_lists(arr1, arr2): + return sorted(arr1 + arr2) + +print merge_sorted_lists(my_list, alices_list) +print "Must be [1, 3, 4, 5, 6, 8, 10, 11, 12, 14, 15, 19]" \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/hical_str_manipulation.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/hical_str_manipulation.py new file mode 100644 index 0000000..ce68048 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/hical_str_manipulation.py @@ -0,0 +1,51 @@ +#!/bin/python + +""" +Build a calendar. + +A meeting is stored as a tuple of integers (start_time, end_time). +These integers represent the number of 30-minute blocks past 9:00am. + +For example: + +(2, 3)# Meeting from 10:00-10:30 am +(6, 9)# Meeting from 12:00-1:30 pm + +Write a function merge_ranges() that takes a list of multiple meeting time ranges and returns a list of condensed ranges. + +For example, given: + + [(0, 1), (3, 5), (4, 8), (10, 12), (9, 10)] + +your function would return: + + [(0, 1), (3, 8), (9, 12)] + +Do not assume the meetings are in order. The meeting times are coming from multiple teams. + +Write a solution that's efficient even when we can't put a nice upper bound on the numbers representing our time ranges. +Here we've simplified our times down to the number of 30-minute slots past 9:00 am. +But we want the function to work even for very large numbers, like Unix timestamps. +In any case, the spirit of the challenge is to merge meetings where start_time and end_time don't have an upper bound. +""" + +def merge_ranges(meetings): + + sorted_meetings = sorted(meetings) + merged_meetings = [sorted_meetings[0]] + + for current_meeting_start, current_meeting_ending in sorted_meetings[1:]: + last_merged_meeting_start, last_merged_meeting_end = merged_meetings[-1] + + if (current_meeting_start <= last_merged_meeting_end): + merged_meetings[-1] = (last_merged_meeting_start, max(last_merged_meeting_end, current_meeting_ending)) + else: + merged_meetings.append((current_meeting_start, current_meeting_ending)) + + return merged_meetings + +if __name__ == '__main__': + + meetings = [(0, 1), (3, 5), (4, 8), (10, 12), (9, 10)] + print(merge_ranges(meetings)) + print("Should return {}".format([(0, 1), (3, 8), (9, 12)])) diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/online_poker.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/online_poker.py new file mode 100644 index 0000000..d5c1aa8 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/online_poker.py @@ -0,0 +1,28 @@ +#!/bin/python + +""" +Write a function to tell us if a full deck of cards shuffled_deck is a single riffle of two other halves half1 and half2. + +We'll represent a stack of cards as a list of integers in the range 1..521..52 (since there are 5252 distinct cards in a deck). +Why do I care? A single riffle is not a completely random shuffle. If I'm right, I can make more informed bets and get rich and finally prove to my ex that I am not a "loser with an unhealthy cake obsession" (even though it's too late now because she let me go and she's never getting me back). +""" + +def is_single_riffle(half1, half2, shuffled_deck, + shuffled_deck_index=0, half1_index=0, half2_index=0): + if shuffled_deck_index == len(shuffled_deck): + return True + + if ((half1_index < len(half1)) and + half1[half1_index] == shuffled_deck[shuffled_deck_index]): + half1_index += 1 + + elif ((half2_index < len(half2)) and + half2[half2_index] == shuffled_deck[shuffled_deck_index]): + half2_index += 1 + else: + return False + + shuffled_deck_index += 1 + return is_single_riffle( + half1, half2, shuffled_deck, shuffled_deck_index, + half1_index, half2_index) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/palindrome.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/palindrome.py new file mode 100644 index 0000000..0caba72 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/palindrome.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +""" +Write an efficient function that checks whether +any permutation of an input string is a palindrome. +""" + +def has_palindrome_permutation(the_string): + unpaired_characters = set() + + for char in the_string: + if char in unpaired_characters: + unpaired_characters.remove(char) + else: + unpaired_characters.add(char) + + return len(unpaired_characters) <= 1 + +str1 = "civic" +print has_palindrome_permutation(str1) +print "Should be True" + +str2 = "ivilc" +print has_palindrome_permutation(str2) +print "Should be False" \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/reverse_in_place.py b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/reverse_in_place.py new file mode 100644 index 0000000..9f5e801 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/other_resources/interview_cake/strings/reverse_in_place.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +""" +Write a function that takes a list of characters and reverses the letters in place. +O(n) time and O(1)O(1) space. +""" + +def reverse_in_place(char_list): + return char_list[::-1] + + +char_list = ['a', 'b', 'c', 'd', 'e', 'f'] + + + +print(char_list) +print(reverse_in_place(char_list)) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/palindome.py b/MY_BOOK/ebook_src/real_interview_problems/palindome.py new file mode 100644 index 0000000..a274417 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/palindome.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +import string + +def sanitize(sentence): + array = sentence.lower() + array = array.strip() + array = array.strip(string.punctuation) + return array + +def check_if_palindrome(array): + if len(array) < 2: + return True + + if array[0] == array[-1]: + return check_if_palindrome(array[1:-1]) + else: + return False + +def check_if_palindrome_iter(array): + i, j = 0, len(array)-1 + + while i <= j: + if array[i] != array[j]: + return False + i += 1 + j -= 1 + + return True + + +if __name__ == '__main__': + sentence = 'hello there' + array = sanitize(sentence) + assert(check_if_palindrome(array) == False) + assert(check_if_palindrome_iter(array) == False) + + sentence = '' + array = sanitize(sentence) + assert(check_if_palindrome(array) == True) + assert(check_if_palindrome_iter(array) == True) + + sentence = 'h' + array = sanitize(sentence) + assert(check_if_palindrome(array) == True) + assert(check_if_palindrome_iter(array) == True) + + sentence = 'Noel sees Leon' + array = sanitize(sentence) + assert(check_if_palindrome(array) == True) + assert(check_if_palindrome_iter(array) == True) + + sentence = 'Noel sees Leon!' + array = sanitize(sentence) + assert(check_if_palindrome(array) == True) + assert(check_if_palindrome_iter(array) == True) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/permutation.py b/MY_BOOK/ebook_src/real_interview_problems/permutation.py new file mode 100644 index 0000000..0287c2b --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/permutation.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def permutation(array): + if len(array) < 2: + return [array] + + result = [] + for index, letter in enumerate(array): + new_array = array[:index] + array[index+1:] + for perm in permutation(new_array): + result.append(letter + perm) + + return result + + + +if __name__ == '__main__': + word = 'abc' + result = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'] + assert(permutation(word) == result) + + word = '' + result = [''] + assert(permutation(word) == result) + + word = 'a' + result = ['a'] + assert(permutation(word) == result) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/queue.py b/MY_BOOK/ebook_src/real_interview_problems/queue.py new file mode 100644 index 0000000..c2ec415 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/queue.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +class Queue(object): + def __init__(self): + self.enq = [] + self.deq = [] + + def enqueue(self, item): + return self.enq.append(item) + + def deque(self): + if not self.deq: + while self.enq: + self.deq.append(self.enq.pop()) + return self.deq.pop() + + def peak(self): + if not self.deq: + while self.enq: + self.deq.append(self.enq.pop()) + if self.deq: + return self.deq[-1] + + def size(self): + return len(self.enq) + len(self.deq) + + def isempty(self): + return not (self.enq + self.deq) + + +if __name__ == '__main__': + q = Queue() + for i in range(1,11): + q.enqueue(i) + print 'Size:', q.size() + print 'Is empty?', q.isempty() + print 'Peak: ', q.peak() + print + print 'Dequeuing...' + for i in range(10): + print q.deque() + print 'Size:', q.size() + print 'Is empty?', q.isempty() + print 'Peak: ', q.peak() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/quick_sort.py b/MY_BOOK/ebook_src/real_interview_problems/quick_sort.py new file mode 100644 index 0000000..2986b57 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/quick_sort.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +def quick_sort(array): + if len(array) < 2: + return array + + # partition + ipivot = len(array)//2 + pivot = array[ipivot] + new_array = array[:ipivot] + array[ipivot+1:] + + left = [x for x in new_array if x <= pivot] + right = [x for x in new_array if x > pivot] + + return quick_sort(left) + [pivot] + quick_sort(right) + + + + +if __name__ == '__main__': + array = [3, 1, 6, 0, 7, 19, 7, 2, 22] + sorted = [0, 1, 2, 3, 6, 7, 7, 19, 22] + assert(quick_sort(array) == sorted) + + array = [] + assert(quick_sort(array) == array) + + array = [1] + assert(quick_sort(array) == array) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/reverse_str.py b/MY_BOOK/ebook_src/real_interview_problems/reverse_str.py new file mode 100644 index 0000000..3109951 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/reverse_str.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +def reverse_str_inplace(_str): + if len(_str) < 2: + return _str + return _str[-1] + reverse_str(_str[1:-1]) + _str[0] + + +def reverse_str(_str): + result = '' + j = len(_str) - 1 + + while j >= 0: + result += _str[j] + + return result + + +if __name__ == '__main__': + _str = '' + result = '' + assert(reverse_str(_str) == result) + assert(reverse_str_inplace(_str) == result) + + _str = 'a' + result = 'a' + assert(reverse_str(_str) == result) + assert(reverse_str_inplace(_str) == result) + + _str = 'abcde' + result = 'edcba' + assert(reverse_str(_str) == result) + assert(reverse_str_inplace(_str) == result) + + _str = 'abcdef' + result = 'fedcba' + assert(reverse_str(_str) == result) + assert(reverse_str_inplace(_str) == result) \ No newline at end of file diff --git a/MY_BOOK/ebook_src/real_interview_problems/stack.py b/MY_BOOK/ebook_src/real_interview_problems/stack.py new file mode 100644 index 0000000..07e9e06 --- /dev/null +++ b/MY_BOOK/ebook_src/real_interview_problems/stack.py @@ -0,0 +1,40 @@ + +#!/usr/bin/env python + +__author__ = "bt3" + + +class Stack(object): + def __init__(self): + self.content = [] + + def push(self, value): + self.content.append(value) + + def pop(self): + if self.content: + return self.content.pop() + else: + return 'Empty List. ' + + def size(self): + return len(self.content) + + def isEmpty(self): + return not bool(self.content) + + def peek(self): + if self.content: + return self.content[-1] + else: + print('Stack is empty.') + + + +if __name__ == '__main__': + q = Stack() + + for i in range(10): + q.push(i) + for i in range(11): + print q.pop() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/requirements.txt b/MY_BOOK/ebook_src/requirements.txt new file mode 100644 index 0000000..e79bb92 --- /dev/null +++ b/MY_BOOK/ebook_src/requirements.txt @@ -0,0 +1,12 @@ +SQLAlchemy==1.3.0 +bpython==0.13.1 +coverage==3.7.1 +curtsies==0.0.34 +graphviz==0.4.2 +ipython==8.10.0 +matplotlib==1.3.1 +nose==1.3.0 +numpy==1.22.0 +scapy==2.4.1 +scikit-learn==0.14.1 +scipy==1.10.0 \ No newline at end of file diff --git a/src/neat_builtin_examples/lists_and_strings/__init__.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/__init__.py similarity index 100% rename from src/neat_builtin_examples/lists_and_strings/__init__.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/__init__.py diff --git a/MY_BOOK/ebook_src/searching_and_sorting/searching/binary_search.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/binary_search.py new file mode 100644 index 0000000..79570cf --- /dev/null +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/binary_search.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def binary_search(array, item, hi=None, lo=0): + ''' + >>> binary_search([2,3,5,6,8,10,15,23], 15) + 6 + >>> binary_search([2,3,5,6,8,10,15,23], 4) + False + >>> binary_search([1,3,4,5,7,8 ,10,12,23], 10) + 6 + >>> binary_search([1,3,4,5,7,8 ,10,12,23], 22) + False + ''' + + hi = hi or len(array) + if hi < lo: + return False + + mid = (hi + lo)//2 + if item == array[mid]: + return mid + elif item < array[mid]: + return binary_search(array, item, hi=mid-1, lo=lo) + else: + return binary_search(array, item, hi=hi, lo=mid+1) + + + + +def binary_search_iter(array, item): + ''' + >>> binary_search_iter([2,3,5,6,8,10,15,23], 15) + 6 + >>> binary_search_iter([2,3,5,6,8,10,15,23], 4) + False + >>> binary_search_iter([1,3,4,5,7,8 ,10,12,23], 10) + 6 + >>> binary_search_iter([1,3,4,5,7,8 ,10,12,23], 22) + False + ''' + lo, hi = 0, len(array) + + while lo < hi: + mid = (hi+lo)//2 + if array[mid] == item: + return mid + elif array[mid] > item: + hi = mid + else: + lo=mid+1 + return False + + + + + + + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/searching_and_sorting/searching/binary_search_matrix.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/binary_search_matrix.py new file mode 100644 index 0000000..98f3d96 --- /dev/null +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/binary_search_matrix.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def binary_search_matrix_rec(m, key, lo=0, hi=None): + ''' + >>> m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + >>> binary_search_matrix_rec(m, 6) + (1, 2) + >>> binary_search_matrix_rec(m, 12) + ''' + if not m: + return None + + rows = len(m) + cols = len(m[0]) + hi = hi or rows*cols + + if hi > lo: + + mid = (hi + lo)//2 + row = mid//cols + col = mid%cols + item = m[row][col] + + if key == item: + return row, col + elif key < item: + return binary_search_matrix_rec(m, key, lo, mid-1) + else: + return binary_search_matrix_rec(m, key, mid+1, hi) + + return None + + + +def binary_search_matrix_iter(m, key): + ''' + + ''' + + if not m: + return None + rows = len(m) + cols = len(m[0]) + lo, hi = 0, rows*cols + + while lo < hi: + mid = (hi + lo)//2 + row = mid//rows + col = mid%rows + item = m[row][col] + if key == item: + return (row, col) + elif key < item: + hi = mid + else: + lo = mid +1 + + return None + + +def searching_matrix(m, key): + ''' + >>> m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + >>> searching_matrix(m, 6) + (1, 2) + >>> searching_matrix(m, 12) + ''' + + if not m: + return None + rows = len(m) + cols = len(m[0]) + i, j = 0, cols -1 + + while i < rows and j > 0: + item = m[i][j] + if key == item: + return (i, j) + elif key < item: + j -= 1 + else: + i += 1 + + return None + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/src/searching_and_sorting/searching/find_item_rotated_sorted_array.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_item_rotated_sorted_array.py similarity index 78% rename from src/searching_and_sorting/searching/find_item_rotated_sorted_array.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/find_item_rotated_sorted_array.py index 26024d2..2c5eadd 100644 --- a/src/searching_and_sorting/searching/find_item_rotated_sorted_array.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_item_rotated_sorted_array.py @@ -1,21 +1,27 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" -''' Given a sorted array that was rotated, find an item with binary search: +''' +Given a sorted array that was rotated, find an item with binary search: ''' def find_element_rot_array(seq, key, lo=0, hi=None): + hi = hi or len(seq) - if hi <= lo: return None # base case: <= for odd and even numbers! + if hi <= lo: + return None # base case: <= for odd and even numbers! + mid = (hi + lo) // 2 - if key == seq[mid]: return mid + + if key == seq[mid]: + return mid # if left is ordered --> we work here if seq[lo] <= seq[mid]: + # now, is the key there? if key < seq[mid] and key >= seq[lo]: return find_element_rot_array(seq, key, lo, mid) @@ -25,6 +31,7 @@ def find_element_rot_array(seq, key, lo=0, hi=None): # right is ordered --> we work here else: + # now, is the key there? if key > seq[mid] and key <= seq[hi-1]: # stupid hi-1!!! return find_element_rot_array(seq, key, mid+1, hi) diff --git a/src/searching_and_sorting/searching/find_max_unimodal_array.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_max_unimodal_array.py similarity index 83% rename from src/searching_and_sorting/searching/find_max_unimodal_array.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/find_max_unimodal_array.py index c38215e..1a57dd5 100644 --- a/src/searching_and_sorting/searching/find_max_unimodal_array.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_max_unimodal_array.py @@ -1,15 +1,15 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - +#!/usr/bin/env python +__author__ = "bt3" def find_max_unimodal_array(A): - if len(A) <= 2 : return None + if len(A) <= 2 : + return None left = 0 right = len(A)-1 + while right > left +1: + mid = (left + right)//2 if A[mid] > A[mid-1] and A[mid] > A[mid+1]: return A[mid] @@ -17,6 +17,7 @@ def find_max_unimodal_array(A): left = mid else: right = mid + return None diff --git a/src/searching_and_sorting/searching/find_sqrt_bin_search.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_sqrt_bin_search.py similarity index 80% rename from src/searching_and_sorting/searching/find_sqrt_bin_search.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/find_sqrt_bin_search.py index 84fcfd1..6bef19f 100644 --- a/src/searching_and_sorting/searching/find_sqrt_bin_search.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_sqrt_bin_search.py @@ -1,14 +1,11 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - +#!/usr/bin/env python +__author__ = "bt3" +''' implement square root using binary search ''' def find_sqrt_bin_search(n, error=0.001): - ''' implement square root using binary search ''' lower = n < 1 and n or 1 upper = n < 1 and 1 or n mid = lower + (upper - lower) / 2.0 diff --git a/src/searching_and_sorting/searching/find_str_array_with_empty_str.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_str_array_with_empty_str.py similarity index 65% rename from src/searching_and_sorting/searching/find_str_array_with_empty_str.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/find_str_array_with_empty_str.py index 90b1245..fa66428 100644 --- a/src/searching_and_sorting/searching/find_str_array_with_empty_str.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_str_array_with_empty_str.py @@ -1,20 +1,22 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" -''' Given a sorted an array with empty strings, we use binary search to find some string (since - the list is sorted): - --> we deal with the empty strings with strip and then run to left and right, or move - mid to the closed non-empty str (remember that the index must be conserved): +''' Given a sorted an array with empty strings, + we use binary search to find some string (since the list is sorted): + --> we deal with the empty strings with strip and then run to left + and right, or move mid to the closed non-empty str (remember that + the index must be conserved): ''' def find_str_array_with_empty_str(seq, s1): - if not seq or not s1: return None + if not seq or not s1: + return None hi = len(seq) lo = 0 + while hi > lo: mid = (hi+lo)//2 @@ -32,9 +34,12 @@ def find_str_array_with_empty_str(seq, s1): right += 1 left -= 1 - if s1 == seq[mid] == s1: return mid - elif s1 < seq[mid]: hi = mid - else: lo = mid + 1 + if s1 == seq[mid] == s1: + return mid + elif s1 < seq[mid]: + hi = mid + else: + lo = mid + 1 diff --git a/src/searching_and_sorting/searching/find_time_occurence_list.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_time_occurence_list.py similarity index 68% rename from src/searching_and_sorting/searching/find_time_occurence_list.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/find_time_occurence_list.py index 291fdb9..c7fa6e0 100644 --- a/src/searching_and_sorting/searching/find_time_occurence_list.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/find_time_occurence_list.py @@ -1,10 +1,8 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" - -def binary_serch_counting(lst1, k, lo=0, hi=None): +def binary_search_counting(lst1, k, lo=0, hi=None): if hi is None: hi = len(lst1) while lo < hi: mid = (lo+hi)//2 @@ -19,12 +17,14 @@ def binary_serch_counting(lst1, k, lo=0, hi=None): def find_time_occurrence_list(seq, k): - """ find how many times a k element appears in a sorted list. One way of doing this is using - collections.OrderedDict to no mess with the sorting, and add entries for every count. This - should be O(n). It has a O(1) space complexity since the size of the dict is fixed. - Another way, since the array is sorted, it to use binary search, since this is only O(logn). + """ find how many times a k element appears in a sorted list. + One way of doing this is using collections.OrderedDict to no + mess with the sorting, and add entries for every count. This + should be O(n). It has a O(1) space complexity since the size of + the dict is fixed. Another way, since the array is sorted, it to + use binary search, since this is only O(logn). """ - index_some_k = binary_serch_counting(seq, k) + index_some_k = binary_search_counting(seq, k) count = 1 sizet = len(seq) diff --git a/src/searching_and_sorting/searching/ordered_sequential_search.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/ordered_sequential_search.py similarity index 91% rename from src/searching_and_sorting/searching/ordered_sequential_search.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/ordered_sequential_search.py index 4f799d8..8f24d20 100644 --- a/src/searching_and_sorting/searching/ordered_sequential_search.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/ordered_sequential_search.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" diff --git a/src/searching_and_sorting/searching/quick_select.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/quick_select.py similarity index 96% rename from src/searching_and_sorting/searching/quick_select.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/quick_select.py index 383b64d..ef5a629 100644 --- a/src/searching_and_sorting/searching/quick_select.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/quick_select.py @@ -1,12 +1,10 @@ +#!/usr/bin/env python -#!/usr/bin/python +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" import random - ''' The simplest way...''' def quickSelect(seq, k): # this part is the same as quick sort diff --git a/src/searching_and_sorting/searching/searching_in_a_matrix.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/searching_in_a_matrix.py similarity index 93% rename from src/searching_and_sorting/searching/searching_in_a_matrix.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/searching_in_a_matrix.py index 7b9c2bb..92a3bdc 100644 --- a/src/searching_and_sorting/searching/searching_in_a_matrix.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/searching_in_a_matrix.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" import numpy diff --git a/src/searching_and_sorting/searching/sequential_search.py b/MY_BOOK/ebook_src/searching_and_sorting/searching/sequential_search.py similarity index 89% rename from src/searching_and_sorting/searching/sequential_search.py rename to MY_BOOK/ebook_src/searching_and_sorting/searching/sequential_search.py index cb876cb..6d389ce 100644 --- a/src/searching_and_sorting/searching/sequential_search.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/searching/sequential_search.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" def sequential_search(seq, n): diff --git a/src/searching_and_sorting/sorting/1.dat b/MY_BOOK/ebook_src/searching_and_sorting/sorting/1.dat similarity index 100% rename from src/searching_and_sorting/sorting/1.dat rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/1.dat diff --git a/src/searching_and_sorting/sorting/2.dat b/MY_BOOK/ebook_src/searching_and_sorting/sorting/2.dat similarity index 100% rename from src/searching_and_sorting/sorting/2.dat rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/2.dat diff --git a/src/searching_and_sorting/sorting/3.dat b/MY_BOOK/ebook_src/searching_and_sorting/sorting/3.dat similarity index 100% rename from src/searching_and_sorting/sorting/3.dat rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/3.dat diff --git a/src/neat_builtin_examples/numbers/__init__.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/__init__.py similarity index 100% rename from src/neat_builtin_examples/numbers/__init__.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/__init__.py diff --git a/src/searching_and_sorting/sorting/bubble_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/bubble_sort.py similarity index 68% rename from src/searching_and_sorting/sorting/bubble_sort.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/bubble_sort.py index d156a22..0d72e77 100644 --- a/src/searching_and_sorting/sorting/bubble_sort.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/bubble_sort.py @@ -1,16 +1,12 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" def bubble_sort(seq): """ Implementation of bubble sort. O(n2) and thus highly ineffective. - :param seq: the sequence to be sorted. - :return: the sorted sequence. """ size = len(seq) -1 for num in range(size, 0, -1): @@ -26,9 +22,6 @@ def test_bubble_sort(module_name='this module'): seq = [4, 5, 2, 1, 6, 2, 7, 10, 13, 8] assert(bubble_sort(seq) == sorted(seq)) - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - if __name__ == '__main__': test_bubble_sort() diff --git a/src/searching_and_sorting/sorting/count_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/count_sort.py similarity index 82% rename from src/searching_and_sorting/sorting/count_sort.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/count_sort.py index 2ee6ea6..8bdfc23 100644 --- a/src/searching_and_sorting/sorting/count_sort.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/count_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" @@ -20,7 +19,6 @@ def count_sort_dict(a): def test_count_sort(): seq = [3, 5, 2, 6, 8, 1, 0, 3, 5, 6, 2, 5, 4, 1, 5, 3] assert(count_sort_dict(seq) == sorted(seq)) - print('Tests passed!') if __name__ == '__main__': diff --git a/src/searching_and_sorting/sorting/gnome_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/gnome_sort.py similarity index 80% rename from src/searching_and_sorting/sorting/gnome_sort.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/gnome_sort.py index 435a9f2..efad801 100644 --- a/src/searching_and_sorting/sorting/gnome_sort.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/gnome_sort.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" def gnome_sort(seq): @@ -20,7 +18,6 @@ def gnome_sort(seq): def test_gnome_sort(): seq = [3, 5, 2, 6, 8, 1, 0, 3, 5, 6, 2, 5, 4, 1, 5, 3] assert(gnome_sort(seq) == sorted(seq)) - print('Tests passed!') if __name__ == '__main__': diff --git a/src/searching_and_sorting/sorting/heap.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/heap.py similarity index 93% rename from src/searching_and_sorting/sorting/heap.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/heap.py index 72a809e..b22326c 100644 --- a/src/searching_and_sorting/sorting/heap.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/heap.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" class Heap(object): diff --git a/src/searching_and_sorting/sorting/heap_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/heap_sort.py similarity index 95% rename from src/searching_and_sorting/sorting/heap_sort.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/heap_sort.py index 38c2ff5..bcbf639 100644 --- a/src/searching_and_sorting/sorting/heap_sort.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/heap_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' Heapsort using Pythons libraries''' diff --git a/src/searching_and_sorting/sorting/insertion_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/insertion_sort.py similarity index 88% rename from src/searching_and_sorting/sorting/insertion_sort.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/insertion_sort.py index e67130c..922e3a6 100644 --- a/src/searching_and_sorting/sorting/insertion_sort.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/insertion_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" @@ -32,7 +31,6 @@ def test_insertion_sort(): seq = [3, 5, 2, 6, 8, 1, 0, 3, 5, 6, 2, 5, 4, 1, 5, 3] assert(insertion_sort(seq) == sorted(seq)) assert(insertion_sort_rec(seq) == sorted(seq)) - print('Tests passed!') if __name__ == '__main__': diff --git a/MY_BOOK/ebook_src/searching_and_sorting/sorting/merge_and_sort_two_arrays.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/merge_and_sort_two_arrays.py new file mode 100644 index 0000000..4af24a8 --- /dev/null +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/merge_and_sort_two_arrays.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +''' +You have two arrays with N integers in them. Merge those arrays using a +recursive algorithm so that the integers in the final array are sorted. +''' + +def merge_arrays(a1, a2): + ''' + >>> merge_arrays([5, 4, 3], [6, 2, 9]) + [2, 3, 4, 5, 6, 9] + >>> merge_arrays([2, 6], [6, 2]) + [2, 2, 6, 6] + >>> merge_arrays([], []) + [] + ''' + # if they are not sorted yet + a1.sort() + a2.sort() + + merge = [] + p1, p2 = 0, 0 + + while p1 < len(a1) and p2 < len(a2): + if a1[p1] <= a2[p2]: + merge.append(a1[p1]) + p1 += 1 + else: + merge.append(a2[p2]) + p2 +=1 + + if a1[p1:]: + merge.extend(a1[p1:]) + + if a2[p2:]: + merge.extend(a2[p2:]) + + return merge + + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/MY_BOOK/ebook_src/searching_and_sorting/sorting/merge_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/merge_sort.py new file mode 100644 index 0000000..fd5ac54 --- /dev/null +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/merge_sort.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def merge_sort(array): + ''' + >>> merge_sort([3 ,5, 1, 2, 10, 6]) + [1, 2, 3, 5, 6, 10] + ''' + if len(array) < 2: + return array + + mid = len(array)//2 + left = merge_sort(array[:mid]) + right = merge_sort(array[mid:]) + + res = [] + i, j = 0, 0 + while i < len(left) and j < len(right): + if left[i] <= right[j]: + res.append(left[i]) + i += 1 + else: + res.append(right[j]) + j += 1 + + if left[i:]: + res.extend(left[i:]) + if right[j:]: + res.extend(right[j:]) + return res + + + +''' Merge sort for files ''' +def merge_files(list_files): + result = [] + final = [] + for filename in list_files: + aux = [] + with open(filename, 'r') as file: + for line in file: + aux.append(int(line)) + result.append(aux) + final.extend(result.pop()) + for l in result: + final = merge(l, final) + return final + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/MY_BOOK/ebook_src/searching_and_sorting/sorting/quick_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/quick_sort.py new file mode 100644 index 0000000..5596d1a --- /dev/null +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/quick_sort.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +def qs(array): + ''' + >>> qs([4,1,6,2,7,9,3]) + [1, 2, 3, 4, 6, 7, 9] + ''' + if len(array) < 2: + return array + + piv = len(array)//2 + piv_element = array[piv] + new_array = array[:piv] + array[piv+1:] + + left = [a for a in new_array if a <= piv_element] + right = [a for a in new_array if a > piv_element] + + return qs(left) + [array[piv]] + qs(right) + + + +# we can also divide them into two functions +def partition(seq): + pi,seq = seq[0],seq[1:] + lo = [x for x in seq if x <= pi] + hi = [x for x in seq if x > pi] + return lo, pi, hi + +def quick_sort_divided(seq): + ''' + >>> quick_sort_divided([4,1,6,2,7,9,3]) + [1, 2, 3, 4, 6, 7, 9] + ''' + if len(seq) < 2: + return seq + lo, pi, hi = partition(seq) + return quick_sort_divided(lo) + [pi] + quick_sort_divided(hi) + + + +if __name__ == '__main__': + import doctest + doctest.testmod() \ No newline at end of file diff --git a/src/searching_and_sorting/sorting/selection_sort.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/selection_sort.py similarity index 82% rename from src/searching_and_sorting/sorting/selection_sort.py rename to MY_BOOK/ebook_src/searching_and_sorting/sorting/selection_sort.py index 72478c4..65fc169 100644 --- a/src/searching_and_sorting/sorting/selection_sort.py +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/selection_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" def selection_sort(seq): @@ -18,7 +17,6 @@ def selection_sort(seq): def test_selection_sort(): seq = [3, 5, 2, 6, 8, 1, 0, 3, 5, 6, 2] assert(selection_sort(seq) == sorted(seq)) - print('Tests passed!') if __name__ == '__main__': diff --git a/MY_BOOK/ebook_src/searching_and_sorting/sorting/sort_anagrams_together.py b/MY_BOOK/ebook_src/searching_and_sorting/sorting/sort_anagrams_together.py new file mode 100644 index 0000000..1a20417 --- /dev/null +++ b/MY_BOOK/ebook_src/searching_and_sorting/sorting/sort_anagrams_together.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' A method to sort an array so that all the anagrams are together. + Since we only want the anagrams to be grouped, we can use a + dictionary for this task. This algorithm is O(n). +''' + +from collections import defaultdict + +def sort_anagrams_together(l1): + ''' + >>> l1 = ['hat', 'ball', 'tha', 'cut', 'labl', 'hta', 'cool', 'cuy', 'uct'] + >>> sort_anagrams_together(l1) + ['cuy', 'cut', 'uct', 'cool', 'ball', 'labl', 'hat', 'tha', 'hta'] + ''' + result = [] + + dict_aux = defaultdict(list) + for word in l1: + key = ''.join(sorted(word)) + dict_aux[key].append(word) + + for key in dict_aux: + result.extend(dict_aux[key]) + + return result + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/src/neat_builtin_examples/sets/__init__.py b/MY_BOOK/ebook_src/trees/__init__.py old mode 100644 new mode 100755 similarity index 100% rename from src/neat_builtin_examples/sets/__init__.py rename to MY_BOOK/ebook_src/trees/__init__.py diff --git a/MY_BOOK/ebook_src/trees/binary_search_tree.py b/MY_BOOK/ebook_src/trees/binary_search_tree.py new file mode 100755 index 0000000..d0802d4 --- /dev/null +++ b/MY_BOOK/ebook_src/trees/binary_search_tree.py @@ -0,0 +1,120 @@ +#!/usr/bin/python + +__author__ = "bt3" + + +class Node(object): + + def __init__(self, item=None,): + + self.item = item + self.left = None + self.right = None + + def __repr__(self): + return '{}'.format(self.item) + + + def _add(self, value): + new_node = Node(value) + + if not self.item: + self.item = new_node.value + + else: + if value > self.item: + self.right = self.right and self.right._add(value) or new_node + elif value < self.item: + self.left = self.left and self.left._add(value) or new_node + else: + print("BSTs do not support repeated items.") + + return self # this is necessary!!! + + + def _search(self, value): + if self.item == value: + return True # or self + + elif self.left and value < self.item: + return self.left._search(value) + + elif self.right and value > self.item: + return self.right._search(value) + + else: + return False + + + def _isLeaf(self): + return not self.right and not self.left + + + def _printPreorder(self): + print self.item + + if self.left: + self.left._printPreorder() + + if self.right: + self.right._printPreorder() + + # Another possibility: use an array (a little bit more expensive): + def _preorder_array(self): + nodes = [] + if self.item: + nodes.append(self.item) + if self.left: + nodes.extend(self.left._preorder_array()) + if self.right: + nodes.extend(self.right._preorder_array()) + return nodes + + + + +class BST(object): + + def __init__(self): + self.root = None + + def add(self, value): + if not self.root: + self.root = Node(value) + else: + self.root._add(value) + + def printPreorder(self): + if self.root: + self.root._printPreorder() + + def search(self, value): + if self.root: + return self.root._search(value) + + def preorder_array(self): + if self.root: + return self.root._preorder_array() + else: + return 'Tree is empty.' + + +if __name__ == '__main__': + + bst = BST() + print "Adding nodes 1 to 10 in the tree..." + for i in range(1, 11): + bst.add(i) + + print + print "Searching for nodes 16 and 6" + print bst.search(16) + print bst.search(6) + + print + print "Printing preorder..." + bst.printPreorder() + + + + diff --git a/MY_BOOK/ebook_src/trees/binary_tree.py b/MY_BOOK/ebook_src/trees/binary_tree.py new file mode 100755 index 0000000..796f1cc --- /dev/null +++ b/MY_BOOK/ebook_src/trees/binary_tree.py @@ -0,0 +1,96 @@ +#!/usr/bin/python + +__author__ = "bt3" + + +class Node(object): + + def __init__(self, item=None,): + self.item = item + self.left = None + self.right = None + + def __repr__(self): + return '{}'.format(self.item) + + + def _add(self, value): + new_node = Node(value) + + if not self.item: + self.item = new_node + elif not self.left: + self.left = new_node + elif not self.right: + self.right = new_node + else: + self.left = self.left._add(value) + + return self + + + def _search(self, value): + if self.item == value: + return True # or self + + found = False # or None, thats diff from BST + if self.left: + found = self.left._search(value) + + if self.right: + found = found or self.right._search(value) + + return found + + + def _isLeaf(self): + return not self.right and not self.left + + + def _preorder(self): + print self.item + if self.left: + self.left._preorder() + if self.right: + self.right._preorder() + + + +class BT(object): + + def __init__(self): + self.root = None + + + def add(self, value): + if not self.root: + self.root = Node(value) + else: + self.root._add(value) + + + def search(self, value): + if self.root: + return self.root._search(value) + + + def preorder(self): + if self.root: + return self.root._preorder() + + +if __name__ == '__main__': + + bt = BT() + print "Adding nodes 1 to 10 in the tree..." + for i in range(1, 11): + bt.add(i) + + print + print "Searching for nodes 16 and 6" + print bt.search(16) + print bt.search(6) + + print + print "Printing preorder..." + bt.preorder() diff --git a/MY_BOOK/ebook_src/trees/binary_tree_generators.py b/MY_BOOK/ebook_src/trees/binary_tree_generators.py new file mode 100644 index 0000000..afafa49 --- /dev/null +++ b/MY_BOOK/ebook_src/trees/binary_tree_generators.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +class Node(object): + def __init__(self, value): + self.value = value + self.right = None + self.left = None + + def add(self, value): + new_node = Node(value) + if not self.value: + self.value = new_node + elif not self.left: + self.left = new_node + elif not self. right: + self.right = new_node + else: + self.left = self.left.add(value) + return self # without this, it doesn't add! + + def search(self, item): + if self.value == item: + return True + found = False + if (self.left and self.left.search(item)) or \ + (self.right and self.right.search(item)): + found = True + return found + + def preorder(self): + yield self.value + if self.left: + for node in self.left.preorder(): + yield node + if self.right: + for node in self.right.preorder(): + yield node + + def postorder(self): + yield self.value + if self.left: + for node in self.left.postorder(): + yield node + if self.right: + for node in self.right.postorder(): + yield node + + def inorder(self): + yield self.value + if self.left: + for node in self.left.inorder(): + yield node + if self.right: + for node in self.right.inorder(): + yield node + + # this is the most basic way to write this function + def preorder_simple(self): + print self.value + if self.left: + self.left.preorder_simple() + if self.right: + self.right.preorder_simple() + + + # Another possibility: use an array (a little bit more expensive): + def preorder_array(self): + nodes = [] + if self.value: + nodes.append(self.value) + if self.left: + nodes.extend(self.left.preorder_array()) + if self.right: + nodes.extend(self.right.preorder_array()) + return nodes + + + +class BT(object): + def __init__(self): + self.root = None + + def add(self, value): + if not self.root: + self.root = Node(value) + else: + self.root.add(value) + + def search(self, item): + if self.root: + return self.root.search(item) + else: + return 'Tree is empty.' + + def preorder(self): + if self.root: + return self.root.preorder() + else: + return 'Tree is empty.' + + def inorder(self): + if self.root: + return self.root.inorder() + else: + return 'Tree is empty.' + + def postorder(self): + if self.root: + return self.root.postorder() + else: + return 'Tree is empty.' + + def preorder_array(self): + if self.root: + return self.root.preorder_array() + else: + return 'Tree is empty.' + + def preorder_simple(self): + if self.root: + return self.root.preorder_simple() + else: + return 'Tree is empty.' + + +if __name__ == '__main__': + tree = BT() + + for i in range(1, 11): + tree.add(i) + + print 'Searching for node 4' + print tree.search(4) + + print 'Searching for node 1' + print tree.search(1) + + print 'Searching for node 12' + print tree.search(12) + + print 'Pre-order generator...' + getree = tree.preorder() + for i in range(10): + print next(getree) + print + print 'Pre-order array...' + + print tree.preorder_array() + + print + print 'Pre-order simple...' + + tree.preorder_simple() + + print + print 'Inorder...' + + getree = tree.inorder() + for i in range(10): + print next(getree) + + print + print 'Postorder...' + + getree = tree.postorder() + for i in range(10): + print next(getree) diff --git a/src/trees/bunchclass.py b/MY_BOOK/ebook_src/trees/bunchclass.py old mode 100644 new mode 100755 similarity index 85% rename from src/trees/bunchclass.py rename to MY_BOOK/ebook_src/trees/bunchclass.py index c7a7748..6e0b440 --- a/src/trees/bunchclass.py +++ b/MY_BOOK/ebook_src/trees/bunchclass.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" class BunchClass(dict): def __init__(self, *args, **kwds): diff --git a/MY_BOOK/ebook_src/trees/check_ancestor.py b/MY_BOOK/ebook_src/trees/check_ancestor.py new file mode 100755 index 0000000..a318958 --- /dev/null +++ b/MY_BOOK/ebook_src/trees/check_ancestor.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from binary_search_tree import BST, Node + +def find_ancestor(path, low_item, high_item): + while path: + current_item = path[0] + + if current_item < low_item: + try: + path = path[2:] + except: + return current_item + + elif current_item > high_item: + try: + path = path[1:] + except: + return current_item + + elif low_item <= current_item <= high_item: + return current_item + + +def find_ancestor2(tree, n1, n2): + if not tree: + return False + + if n1 <= tree.item and n2 >= tree.item or (not tree.left and not tree.right) : + return tree.item + + if tree.left and (n1 < tree.item and n2 < tree.item): + return find_ancestor(tree.left, n1, n2) or tree.item + + if tree.right and (n1 > tree.item and n2 > tree.item): + return find_ancestor(tree.right, n1, n2) or tree.item + + + +if __name__ == '__main__': + bst = BST() + l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] + for i in l: + bst.add(i) + nodes = bst.preorder_array() + + print 'Original: ', l + print 'Preorder: ', nodes + + print 'Method 1: ' + print 'Ancestor for 3, 11:', find_ancestor(nodes, 3, 11) + + print 'Method 2: ' + print 'Ancestor for 3, 11: ', find_ancestor2(bst.root, 3, 11) diff --git a/MY_BOOK/ebook_src/trees/check_if_balanced.py b/MY_BOOK/ebook_src/trees/check_if_balanced.py new file mode 100755 index 0000000..3e6d5fb --- /dev/null +++ b/MY_BOOK/ebook_src/trees/check_if_balanced.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +from binary_search_tree import BST, Node +from binary_tree import BT, Node + + + +def isBalanced(node, left=0, right=0): + if not node: + return (left - right) < 2 + + return isBalanced(node.left, left+1, right) and \ + isBalanced(node.right, left, right+1) + + + + +if __name__ == '__main__': + bt = BST() + for i in range(1, 10): + bt.add(i) + + assert(isBalanced(bt.root) == True) + + bt = BT() + for i in range(1, 10): + bt.add(i) + + assert(isBalanced(bt.root) == False) diff --git a/MY_BOOK/ebook_src/trees/check_if_bst.py b/MY_BOOK/ebook_src/trees/check_if_bst.py new file mode 100755 index 0000000..eb8e8da --- /dev/null +++ b/MY_BOOK/ebook_src/trees/check_if_bst.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from binary_search_tree import BST, Node +from binary_tree import BT, Node + + +def isBST(node, min_node=float("-infinity"), maxVal=float("infinity")): + if not node: + return True + + if not min_node <= node.item <= maxVal: + return False + + return isBST(node.left, min_node, node.item) and \ + isBST(node.right, node.item, maxVal) + + + +def isBST_other_method(node, max_node=None, min_node=None): + + if not node: + return True + + left, right = True, True + min_node = min_node or float('inf') + max_node = max_node or -float('inf') + + if node.left: + if node.left.item > node.item or node.left.item > max_node: + left = False + else: + max_node = node.item + left = isBST(node.left, max_node, min_node) + + if node.right: + if node.right.item < node.item or node.right.item < min_node: + right = False + else: + min_node = node.item + right = isBST(node.right, max_node, min_node) + + return left and right + + + + + +if __name__ == '__main__': + bt = BST() + for i in range(1, 10): + bt.add(i) + + assert(isBST(bt.root) == True) + + bt = BT() + for i in range(1, 10): + bt.add(i) + + assert(isBST(bt.root) == False) + + diff --git a/MY_BOOK/ebook_src/trees/check_largest_item.py b/MY_BOOK/ebook_src/trees/check_largest_item.py new file mode 100755 index 0000000..3428d60 --- /dev/null +++ b/MY_BOOK/ebook_src/trees/check_largest_item.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from binary_search_tree import BST, Node + +def largest(node): + + if node.right: + return largest(node.right) + return node.item + + +if __name__ == '__main__': + + + bst = BST() + l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] + for i in l: + bst.add(i) + + print(largest(bst.root)) diff --git a/src/trees/tree.py b/MY_BOOK/ebook_src/trees/simple_tree.py old mode 100644 new mode 100755 similarity index 89% rename from src/trees/tree.py rename to MY_BOOK/ebook_src/trees/simple_tree.py index 5bd02f4..90480e2 --- a/src/trees/tree.py +++ b/MY_BOOK/ebook_src/trees/simple_tree.py @@ -1,11 +1,12 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" """ A class for a simple tree """ class SimpleTree(object): + def __init__(self, value=None, children = None): self.value = value self.children = children diff --git a/MY_BOOK/ebook_src/trees/transversal.py b/MY_BOOK/ebook_src/trees/transversal.py new file mode 100755 index 0000000..d3e3bf2 --- /dev/null +++ b/MY_BOOK/ebook_src/trees/transversal.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +from collections import deque +from binary_search_tree import BST, Node +from binary_tree import BT, Node + + +def BFT(tree): + current = tree.root + nodes = [] + queue = deque() + queue.append(current) + + while queue: + current = queue.popleft() + nodes.append(current.item) + if current.left: + queue.append(current.left) + if current.right: + queue.append(current.right) + + return nodes + + +def preorder(tree, nodes=None): + nodes = nodes or [] + if tree: + nodes.append(tree.item) + if tree.left: + preorder(tree.left, nodes) + if tree.right: + preorder(tree.right, nodes) + return nodes + + +def postorder(tree, nodes=None): + nodes = nodes or [] + if tree: + if tree.left: + nodes = postorder(tree.left, nodes) + if tree.right: + nodes = postorder(tree.right, nodes) + nodes.append(tree.item) + + return nodes + + +def inorder(tree, nodes=None): + nodes = nodes or [] + if tree: + if tree.left: + nodes = inorder(tree.left, nodes) + nodes.append(tree.item) + if tree.right: + nodes = inorder(tree.right, nodes) + return nodes + + +if __name__ == '__main__': + + + # bt + bt = BT() + l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] + for i in l: + bt.add(i) + print 'BT...' + print 'Original: ', l + print 'Preorder: ', preorder(bt.root) + print 'Postorder: ', postorder(bt.root) + print 'Inorder: ', inorder(bt.root) + print 'Breath: ', BFT(bt) + + # bst + bst = BST() + l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] + for i in l: + bst.add(i) + + print + print 'BST ...' + print 'Original: ', l + print 'Preorder: ', preorder(bst.root) + print 'Postorder: ', postorder(bst.root) + print 'Inorder: ', inorder(bst.root) + print 'Breath: ', BFT(bst) diff --git a/MY_BOOK/ebook_src/trees/trie.py b/MY_BOOK/ebook_src/trees/trie.py new file mode 100755 index 0000000..a73c531 --- /dev/null +++ b/MY_BOOK/ebook_src/trees/trie.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +__author__ = "bt3" + + +''' +Implement a trie. (Write the API and code for inserting into a trie). +''' + +def make_trie(*args): + trie = {} + + for word in args: + temp_trie = trie + for letter in word: + temp_trie = temp_trie.setdefault(letter, {}) + temp_trie = temp_trie.setdefault('_end_', '_end_') + + return trie + + +def in_trie(trie, word): + temp_trie = trie + for letter in word: + if letter not in temp_trie: + return False + temp_trie = temp_trie[letter] + return True + + +def remove_from_trie(trie, word, depth): + if word and word[depth] not in trie: + return False + + if len(word) == depth + 1: + del trie[word[depth]] + if not trie: + return True + return False + else: + temp_trie = trie + + if remove_from_trie(temp_trie[word[depth]], word, depth + 1): + if temp_trie: + del temp_trie[word[depth]] + return not temp_trie + return False + + +if __name__ == '__main__': + trie = make_trie('hello', 'abc', 'baz', 'bar', 'barz') + print 'This is the trie:' + print trie + + assert(in_trie(trie, 'hello') == True) + assert(in_trie(trie, 'bar') == True) + assert(in_trie(trie, 'bab') == False) + assert(in_trie(trie, 'zzz') == False) + + remove_from_trie(trie, 'abc', 0) + assert(in_trie(trie, 'abc') == False) + + + + diff --git a/README.md b/README.md index d1ad764..f9f15db 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,67 @@ -Python and Algorithms & Data Structures -======================================= +## šŸ‘¾šŸ master algorithms with python (and my book šŸ–¤) -This repository contains a comprehensive study of Algorithms & Data Structures in Python, including an ["e-book" I wrote](http://mariwahl.us/docs/algorithms_in_python.pdf). - -![](http://i.imgur.com/fYPlwpQ.png) +
-Source Code Structure ---------------------- +

+ +

+ +
+ +--- + +### šŸ“– algorithms and data structures: learn with my examples! (2023) + +
+ +* šŸ˜šŸ˜šŸ˜šŸ™. **[arrays and strings](arrays_and_strings)** +* šŸ˜šŸ˜šŸ™šŸ˜. **[bit operations](bit_operations)** +* šŸ˜šŸ˜šŸ™šŸ™. **[dynamic programming](dynamic_programming)** +* šŸ˜šŸ™šŸ˜šŸ˜. **[graphs](graphs)** +* šŸ˜šŸ™šŸ˜šŸ™. **[hash objects](hash_objects)** +* šŸ˜šŸ™šŸ™šŸ˜. **[heaps](heaps)** +* šŸ˜šŸ™šŸ™šŸ™. **[linked lists](linked_lists)** +* šŸ™šŸ˜šŸ˜šŸ˜. **[math](math)** +* šŸ™šŸ˜šŸ˜šŸ™. **[queues](queues)** +* šŸ™šŸ˜šŸ™šŸ˜. **[searching](searching)** +* šŸ™šŸ˜šŸ™šŸ™. **[sets](sets)** +* šŸ™šŸ™šŸ˜šŸ˜. **[sorting](sorting)** +* šŸ™šŸ™šŸ˜šŸ™. **[stacks](stacks)** +* šŸ™šŸ™šŸ™šŸ˜. **[trees](trees)** +* šŸ™šŸ™šŸ™šŸ™. **[tries](tries)** + +
-src/ +--- -ā”œā”€ā”€ abstract_structures +### [šŸ“– my book on algorithms and data structure: open-source for you! (2014)](MY_BOOK) - ā”œā”€ā”€ heap +
- ā”œā”€ā”€ linked_lists - - ā”œā”€ā”€ queues - - └── stacks - -ā”œā”€ā”€ builtin_structures - - ā”œā”€ā”€ arrays_and_strings - - ā”œā”€ā”€ dicts - - ā”œā”€ā”€ lists - - ā”œā”€ā”€ numbers - - ā”œā”€ā”€ sets - - ā”œā”€ā”€ strings - - └── tuples - -ā”œā”€ā”€ graphs_and_trees - - ā”œā”€ā”€ trees - -ā”œā”€ā”€ programming_paradigms - - ā”œā”€ā”€ dynamic_programming - - ā”œā”€ā”€ modules - - └── oop - -└── searching_and_sorting - - ā”œā”€ā”€ searching - - ā”œā”€ā”€ sorting +- **āž”ļø [one of the first-ever publications solving classic algorithm and data structure problems in python, published by hanbit media](https://www.hanbit.co.kr/store/books/look.php?p_code=B8465804191)**. +- **āž”ļø [last time i checked, it had 4.6/5 stars and 33 reviews (not bad for a book written in school by a self-taught!)](https://www.hanbit.co.kr/store/books/look.php?p_code=B8465804191)**. +- **āž”ļø [this repo used to have 600+ stars and 300 forks before šŸ’© happened šŸ˜ž (here is a proof)](MY_BOOK/600_stars.png)**. +- **āž”ļø [just for fun: this book as a reference for a CMU computer science class](https://www.andrew.cmu.edu/user/ramesh/teaching/course/48784.pdf)**. +
+

+ -Further Learning ------------------ -[Check out my lessons in machine learning.] (https://github.com/mariwahl/Machine-Learning-Lessons) +
+
+
-[Check out my lessons in numerical methods.](https://github.com/mariwahl/Numerical-Methods-for-Physics) +--- +### external resources -[Neat Problems in Python and Flask](https://github.com/mariwahl/Neat-Problems-in-Python-and-Flask) +
+* **[big-o complexities chart and explanation](https://www.bigocheatsheet.com/)** - -Be Social! ----------- -Please drop me a line or submit a patch if you have any suggestions! \ No newline at end of file diff --git a/arrays_and_strings/3rd_distinct_n.py b/arrays_and_strings/3rd_distinct_n.py new file mode 100644 index 0000000..dbaa778 --- /dev/null +++ b/arrays_and_strings/3rd_distinct_n.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +''' +Given an integer array nums, return the third distinct maximum +number in this array. If the third maximum does not exist, +return the maximum number. + +Do it O(n). +''' + +import math + + +def third_max(nums: list[int]) -> int: + + first_max = -math.inf + second_max = -math.inf + third_max = -math.inf + + for n in nums: + + if n == first_max or n == second_max or n == third_max: + continue + elif n > first_max: + third_max = second_max + second_max = first_max + first_max = n + elif n > second_max: + third_max = second_max + second_max = n + elif n > third_max: + third_max = n + + if third_max == -math.inf: + third_max = max(second_max, first_max) + + return third_max + + +if __name__ == "__main__": + + nums = [3,2,1] + assert(third_max(nums) == 1) diff --git a/arrays_and_strings/README.md b/arrays_and_strings/README.md new file mode 100644 index 0000000..7ea7cdc --- /dev/null +++ b/arrays_and_strings/README.md @@ -0,0 +1,406 @@ +## arrays and strings + +
+ +* arrays and strings hold values of the same type at contiguous memory locations with the advantage of storing multiple elements of the same type with one single variable name. + +* we are usually concerned with two things: the index of an element, and the element itself. + +* accessing elements is fast as long as you have the index (as opposed to linked lists that need to be traversed from the head). + +* addition or removal of elements into/from the middle of an array is slow because the remaining elements need to be shifted to accommodate the new/missing element (unless they are inserted/removed at the end of the list). + +* **subarray**: a range of contiguous values within an array (for example, in `[2, 3, 6, 1, 5, 4]`, `[3, 6, 1]` is a subarray while `[3, 1, 5]` is not). + +* **subsequence**: a sequence derived from the given sequence without changing the order (for example, in `[2, 3, 6, 1, 5, 4]`, `[3, 1, 5]` is a subsequence but `[3, 5, 1]` is not). + +
+ +---- + +### two-pointer technique + +
+ +* a typical scenario is when you want to iterate the array from two ends to the middle or when pointers can cross each others (or even be in different arrays). + +* another scenario is when you need one slow-runner and one fast-runner at the same time (so that you can determine the movement strategy for both pointers). + +* in any case, this technique is usually used when the array is sorted. + +* in the **sliding window** technique, the two pointers usually move in the same direction and never overtake each other. examples are: longest substring without repeating characters, minimum size subarray sum, and minimum window substring. + +
+ +---- + +### intervals + +
+ +* checking if two intervals overlap: + +```python +def is_overlap(a, b): + return a[0] < b[1] and b[0] < a[1] +``` + +
+ +* merging two intervals: + +```python +def merge_overlapping_intervals(a, b): + return [min(a[0], b[0]), max(a[1], b[1])] +``` + + +
+ +--- + +### two-dimensional arrays + +
+ +* a matrix is a 2d array. they can be used to represent graphs where each node is a cell on the matrix which has 4 neighbors (except those cells on the edge and corners). + +* in some languages (like C++), 2d arrays are represented as 1d, so an array of `m * n` elements represents `array[i][j]` as `array[i * n + j]`. + +* creating an empty matrix: + +
+ +```python +zero_matrix = [ [0 for _ in range(len(matrix[0]))] for _ in range(len(matrix)) ] +``` + +
+ +* copying a matrix: + +
+ +```python +copied_matrix = [ row[:] for row in mattrix ] +``` + +
+ +* the transpose of a matrix can be found by interchanging its rows into columns or columns into rows: + +
+ +```python +transposed = zip(*matrix) +``` + +
+ +--- + +### check if mountain + +
+ +```python +def valid_mountain_array(arr: list[int]) -> bool: + + last_number, mountain_up = arr[0], True + + for i, n in enumerate(arr[1:]): + + if n > last_number: + if mountain_up == False: + return False + + elif n < last_number: + if i == 0: + return False + mountain_up = False + + else: + return False + + last_number = n + + return not mountain_up +``` + +
+ +--- + +### duplicate zeros in place + +
+ +```python +def duplicate_zeros(arr: list[int]) -> list[int]: + + i = 0 + while i < len(arr): + + if arr[i] == 0 and i != len(arr) - 1: + + range_here = len(arr) - (i + 2) + while range_here > 0: + arr[i + range_here + 1] = arr[i + range_here] + range_here -= 1 + + arr[i+1] = 0 + i += 2 + + else: + i += 1 + + return arr +``` + +
+ +---- + +### remove duplicates in place + +
+ +```python +def remove_duplicates(nums: list[int]) -> int: + + arr_i, dup_i = 0, 1 + + while arr_i < len(nums) and dup_i < len(nums): + + if nums[arr_i] == nums[dup_i]: + dup_i += 1 + + else: + arr_i += 1 + nums[arr_i] = nums[dup_i] + + for i in range(arr_i + 1, dup_i): + nums[i] = '_' + + return dup_i - arr_i - 1, nums +``` + +
+ +--- + +### anagrams + +
+ +* to determine if two strings are anagrams, there are a few approaches: + - sorting both strings should produce the same string (`O(N log(N))` time and `O(log(N))` space. + - if we map each character to a prime number and we multiply each mapped number together, anagrams should have the same multiple (prime factor decomposition, `O(N)`). + - frequency counting of characters can determine whether they are anagram (`O(N)`). + +
+ +```python +def is_anagram(string1, string2) -> bool: + + string1 = string1.lower() + string2 = string2.lower() + + if len(string1) != len(string2): + return False + + for c in string1: + if c not in string2: + return False + + return True +``` + +
+ + + +---- + +### palindromes + +
+ +* ways to determine if a string is a palindrome: + * reverse the string and they should be equal. + * have two pointers at the start and end of the string, moving the pointers until they meet. + +
+ +```python +def is_palindrome(sentence): + + sentence = sentence.strip(' ') + if len(sentence) < 2: + return True + + if sentence[0] == sentence[-1]: + return is_palindrome(sentence[1:-1]) + + return False +``` + + +
+ +```python +def is_permutation_of_palindromes(some_string): + + aux_dict = {} + + for c in some_string.strip(): + + if c in aux_dict.keys(): + aux_dict[c] -= 1 + else: + aux_dict[c] = 1 + + for v in aux_dict.values(): + if v != 0: + return False + + return True +``` + + +
+ + + +--- + +### intersection of two arrays + +
+ +```python +def intersect(nums1: list[int], nums2: list[int]) -> list[int]: + + result = [] + set_nums = set(nums1) & set(nums2) + counter = Counter(nums1) & Counter(nums2) + + for n in set_nums: + result.extend([n] * counter[n]) + + return result +``` + +
+ +--- + + +### check if isomorphic + +
+ +```python +def is_isomorphic(s: str, t: str) -> bool: + + map_s_to_t = {} + map_t_to_s = {} + + for ss, tt in zip(s, t): + + if (ss not in map_s_to_t) and (tt not in map_t_to_s): + map_s_to_t[ss] = tt + map_t_to_s[tt] = ss + + elif (map_s_to_t.get(ss) != tt) or (map_t_to_s.get(tt) != ss): + return False + + return True +``` + +
+ +--- + +### absolute difference between the sums of a matrix's diagonals + +
+ +```python + +def diagonal_difference(arr): + + diag_1 = 0 + diag_2 = 0 + + i, j = 0, len(arr) - 1 + + while i < len(arr) and j >= 0: + + diag_1 += arr[i][i] + diag_2 += arr[i][j] + i += 1 + j -= 1 + + return diag_1, diag_2, abs(diag_1 - diag_2) +``` + + + +
+ +--- + +### find permutations + +
+ +```python + + +def permutations(string) -> list: + + if len(string) == 1: + return [string] + + result = [] + for i, char in enumerate(string): + for perm in permutation(string[:i] + string[i+1:]): + result += [char + perm] + + return result +``` + +
+ +--- + +### length of the longest substring + +
+ +```python +def length_longest_substring(s) -> int: + + result = "" + this_longest_string = "" + i = 0 + + for c in s: + j = 0 + + while j < len(this_longest_string): + + if c == this_longest_string[j]: + if len(this_longest_string) > len(result): + result = this_longest_string + this_longest_string = this_longest_string[j+1:] + + j += 1 + + this_longest_string += c + + return result, this_longest_string +``` + +
diff --git a/arrays_and_strings/check_if_exist.py b/arrays_and_strings/check_if_exist.py new file mode 100644 index 0000000..15ec58b --- /dev/null +++ b/arrays_and_strings/check_if_exist.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +""" +Given an array arr of integers, check if there exist two indices i and j such that : + +i != j +0 <= i, j < arr.length +arr[i] == 2 * arr[j] +""" + + +def check_if_exist(arr: list[int]) -> bool: + + aux_dict = {} + + for i, num in enumerate(arr): + aux_dict[2 * num] = i + + for j, num in enumerate(arr): + if num in aux_dict.keys() and j != aux_dict[num]: + return (j, aux_dict[num]) + + + return False + +if __name__ == "__main__": + + arr = [-2, 0, 10, -19, 4, 6, -8] + print(check_if_exist(arr)) diff --git a/arrays_and_strings/check_mountain.py b/arrays_and_strings/check_mountain.py new file mode 100644 index 0000000..c29cd00 --- /dev/null +++ b/arrays_and_strings/check_mountain.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +''' +Given an array of integers arr, return true if and only if it is a valid mountain array. +An array is a moutain array if and only if: + +arr.length >= 3 +There exists some i with 0 < i < arr.length - 1 such that: +arr[0] < arr[1] < ... < arr[i - 1] < arr[i] +arr[i] > arr[i + 1] > ... > arr[arr.length - 1] +''' + +def valid_mountain_array(arr: list[int]) -> bool: + + last_number, mountain_up = arr[0], True + + for i, n in enumerate(arr[1:]): + + if n > last_number: + if mountain_up == False: + return False + + elif n < last_number: + if i == 0: + return False + mountain_up = False + + else: + return False + + last_number = n + + return not mountain_up + diff --git a/arrays_and_strings/check_permutation_strings_is_palindrome.py b/arrays_and_strings/check_permutation_strings_is_palindrome.py new file mode 100644 index 0000000..44efd9f --- /dev/null +++ b/arrays_and_strings/check_permutation_strings_is_palindrome.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def is_permutation_of_palindromes(some_string): + + aux_dict = {} + + for c in some_string.strip(): + + if c in aux_dict.keys(): + aux_dict[c] -= 1 + else: + aux_dict[c] = 1 + + for v in aux_dict.values(): + if v != 0: + return False + + return True diff --git a/arrays_and_strings/duplicate_zeros_inplace.py b/arrays_and_strings/duplicate_zeros_inplace.py new file mode 100644 index 0000000..055d41a --- /dev/null +++ b/arrays_and_strings/duplicate_zeros_inplace.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +# Given a fixed-length integer array arr, duplicate each occurrence of zero, +# shifting the remaining elements to the right. + + +def duplicate_zeros(arr: list[int]) -> list[int]: + + i = 0 + while i < len(arr): + + if arr[i] == 0 and i != len(arr) - 1: + + range_here = len(arr) - (i + 2) + while range_here > 0: + arr[i + range_here + 1] = arr[i + range_here] + range_here -= 1 + + arr[i+1] = 0 + i += 2 + + else: + i += 1 + + return arr diff --git a/arrays_and_strings/intersection_two_arrays.py b/arrays_and_strings/intersection_two_arrays.py new file mode 100644 index 0000000..cc91c7e --- /dev/null +++ b/arrays_and_strings/intersection_two_arrays.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def intersect(nums1: list[int], nums2: list[int]) -> list[int]: + + result = [] + set_nums = set(nums1) & set(nums2) + counter = Counter(nums1) & Counter(nums2) + + for n in set_nums: + result.extend([n] * counter[n]) + + return result + diff --git a/arrays_and_strings/is_anagram.py b/arrays_and_strings/is_anagram.py new file mode 100644 index 0000000..989409b --- /dev/null +++ b/arrays_and_strings/is_anagram.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def is_anagram(string1, string2) -> bool: + + string1 = string1.lower() + string2 = string2.lower() + + if len(string1) != len(string2): + return False + + for c in string1: + if c not in string2: + return False + + return True diff --git a/arrays_and_strings/is_isomorphic.py b/arrays_and_strings/is_isomorphic.py new file mode 100644 index 0000000..c5fd564 --- /dev/null +++ b/arrays_and_strings/is_isomorphic.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def is_isomorphic(s: str, t: str) -> bool: + + map_s_to_t = {} + map_t_to_s = {} + + for ss, tt in zip(s, t): + + if (ss not in map_s_to_t) and (tt not in map_t_to_s): + map_s_to_t[ss] = tt + map_t_to_s[tt] = ss + + elif (map_s_to_t.get(ss) != tt) or (map_t_to_s.get(tt) != ss): + return False + + return True diff --git a/arrays_and_strings/longest_non_repeating.py b/arrays_and_strings/longest_non_repeating.py new file mode 100644 index 0000000..cd9d0d4 --- /dev/null +++ b/arrays_and_strings/longest_non_repeating.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def length_longest_substring(s) -> int: + + result = "" + this_longest_string = "" + i = 0 + + for c in s: + j = 0 + + while j < len(this_longest_string): + + if c == this_longest_string[j]: + if len(this_longest_string) > len(result): + result = this_longest_string + this_longest_string = this_longest_string[j+1:] + + j += 1 + + this_longest_string += c + + return result, this_longest_string + diff --git a/arrays_and_strings/matrix_sum_diagonals.py b/arrays_and_strings/matrix_sum_diagonals.py new file mode 100644 index 0000000..ae00c52 --- /dev/null +++ b/arrays_and_strings/matrix_sum_diagonals.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def diagonal_difference(arr): + + diag_1 = 0 + diag_2 = 0 + + i, j = 0, len(arr) - 1 + + while i < len(arr) and j >= 0: + + diag_1 += arr[i][i] + diag_2 += arr[i][j] + i += 1 + j -= 1 + + return diag_1, diag_2, abs(diag_1 - diag_2) + diff --git a/arrays_and_strings/merge_inplace.py b/arrays_and_strings/merge_inplace.py new file mode 100644 index 0000000..d6703e9 --- /dev/null +++ b/arrays_and_strings/merge_inplace.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +""" +You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two +integers m and n, representing the number of elements in nums1 and nums2 respectively. + +Merge nums1 and nums2 into a single array sorted in non-decreasing order. + +The final sorted array should not be returned by the function, +but instead be stored inside the array nums1. +To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements +that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n. +""" + +def merge(big_list: list[int], m: int, small_list: list[int], n: int) -> None: + + index_big, index_small, index_backward = m - 1, n - 1, m + n - 1 + + while index_big >= 0 and index_small >= 0: + + if small_list[index_small] > big_list[index_big]: + big_list[index_backward] = small_list[index_small] + index_small -= 1 + else: + big_list[index_backward] = big_list[index_big] + index_big -= 1 + + index_backward -= 1 + + while index_backward >= 0 and index_big >= 0: + big_list[index_backward] = big_list[index_big] + index_backward -= 1 + index_big -= 1 + + while index_backward >= 0 and index_small >= 0: + big_list[index_backward] = small_list[index_small] + index_backward -= 1 + index_small -= 1 diff --git a/arrays_and_strings/move_zeros_inplace.py b/arrays_and_strings/move_zeros_inplace.py new file mode 100644 index 0000000..ae8cf7d --- /dev/null +++ b/arrays_and_strings/move_zeros_inplace.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +''' +Given an integer array nums, move all 0's to the end of it while +maintaining the relative order of the non-zero elements. + +Note that you must do this in-place without making a copy of the array. +Example 1: + +Input: nums = [0,1,0,3,12] +Output: [1,3,12,0,0] +Example 2: + +Input: nums = [0] +Output: [0] +''' + + +def move_zeroes(nums: list[int]) -> list[int]: + + i = 0 + + while i < len(nums) - 1: + + if nums[i] == 0: + j = i + 1 + while nums[j] == 0 and j < len(nums) - 1: + j += 1 + + nums[i], nums[j] = nums[j], nums[i] + + i += 1 + + + return nums diff --git a/arrays_and_strings/palindrome.py b/arrays_and_strings/palindrome.py new file mode 100644 index 0000000..ad39b0c --- /dev/null +++ b/arrays_and_strings/palindrome.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def is_palindrome(sentence): + + sentence = sentence.strip(' ') + if len(sentence) < 2: + return True + + if sentence[0] == sentence[-1]: + return is_palindrome(sentence[1:-1]) + + return False diff --git a/arrays_and_strings/permutations.py b/arrays_and_strings/permutations.py new file mode 100644 index 0000000..f778c12 --- /dev/null +++ b/arrays_and_strings/permutations.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def permutations(string) -> list: + + if len(string) == 1: + return [string] + + result = [] + for i, char in enumerate(string): + for perm in permutation(string[:i] + string[i+1:]): + result += [char + perm] + + return result diff --git a/arrays_and_strings/pivot_index_array.py b/arrays_and_strings/pivot_index_array.py new file mode 100644 index 0000000..cb1336b --- /dev/null +++ b/arrays_and_strings/pivot_index_array.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def pivot_index(nums): + + s, left_sum = sum(nums), 0 + + for i, x in enumerate(nums): + + if left_sum == (s - left_sum - x): + return i + + left_sum += x + + return -1 diff --git a/arrays_and_strings/playing_with_strings.py b/arrays_and_strings/playing_with_strings.py new file mode 100644 index 0000000..1d1bb67 --- /dev/null +++ b/arrays_and_strings/playing_with_strings.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def reverse_array_in_place(array): + return array[::-1] diff --git a/arrays_and_strings/remove_dups_inplace.py b/arrays_and_strings/remove_dups_inplace.py new file mode 100644 index 0000000..a63a715 --- /dev/null +++ b/arrays_and_strings/remove_dups_inplace.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + + +def remove_duplicates(nums: list[int]) -> int: + + arr_i, dup_i = 0, 1 + + while arr_i < len(nums) and dup_i < len(nums): + + if nums[arr_i] == nums[dup_i]: + dup_i += 1 + + else: + arr_i += 1 + nums[arr_i] = nums[dup_i] + + for i in range(arr_i + 1, dup_i): + nums[i] = '_' + + return dup_i - arr_i - 1, nums + diff --git a/arrays_and_strings/return_matrix_in_spiral.py b/arrays_and_strings/return_matrix_in_spiral.py new file mode 100644 index 0000000..ba13ae3 --- /dev/null +++ b/arrays_and_strings/return_matrix_in_spiral.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def spiral_order(matrix): + + result = [] + rows, cols = len(matrix), len(matrix[0]) + up = left = 0 + right = cols - 1 + down = rows - 1 + + while len(result) < rows * cols: + for col in range(left, right + 1): + result.append(matrix[up][col]) + + for row in range(up + 1, down + 1): + result.append(matrix[row][right]) + + if up != down: + for col in range(right - 1, left - 1, -1): + result.append(matrix[down][col]) + + if left != right: + for row in range(down - 1, up, -1): + result.append(matrix[row][left]) + + left += 1 + right -= 1 + up += 1 + down -= 1 + + return result diff --git a/arrays_and_strings/two_sums.py b/arrays_and_strings/two_sums.py new file mode 100644 index 0000000..ac133e5 --- /dev/null +++ b/arrays_and_strings/two_sums.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def two_sum(nums: list[int], target: int) -> list[int]: + + aux_dict = {} + for i, n in enumerate(nums): + complement = target - n + + if complement in aux_dict: + return [aux_dict[complement][0], i] + + aux_dict[n] = (i, n) + diff --git a/arrays_and_strings/unique_word_abbreviation.py b/arrays_and_strings/unique_word_abbreviation.py new file mode 100644 index 0000000..6394018 --- /dev/null +++ b/arrays_and_strings/unique_word_abbreviation.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +''' +The abbreviation of a word is a concatenation of its first letter, +the number of characters between the first and last letter, and its +last letter. If a word has only two characters, then it is an abbreviation of itself. +Returns true if either of the following conditions are met (otherwise returns false): +- There is no word in dictionary whose abbreviation is equal to word's abbreviation. +- For any word in dictionary whose abbreviation is equal to word's abbreviation, +that word and word are the same. +''' + +class ValidWordAbbr: + + def __init__(self, dictionary): + + self.dict = collections.defaultdict(set) + for w in dictionary: + aux_dict[self.get_abr(w)].add(w) + + return aux_dict + + def get_abr(self, word): + + return word[0] + str(len(word[1:-1])) + word[-1] if len(word) != 2 else word + + def is_unique(self, word: str) -> bool: + + abr = self.get_abr(word) + words = self.dict[abr] + + return len(words) == 0 or (len(words) == 1 and word in words) + diff --git a/bit_operations/README.md b/bit_operations/README.md new file mode 100644 index 0000000..d41b63c --- /dev/null +++ b/bit_operations/README.md @@ -0,0 +1,299 @@ +## bit manipulation + + +
+ +### techniques + +
+ +* test if kth bit is set: `num & (1 << k) != 0` + +* set kth bit: `num |= (1 << k)` + +* turn off kth bit: `num &= ~(1 << k)` + +* toggle the kth bit: `num ^= (1 << k)` + +* multiply by `2^k`: `num << k` + +* divide by `2^k`: `num >> k` + +* check if a number is a power of 2: `(num & num - 1) == 0` or `(num & (-num)) == num` + +* swapping two variables: `num1 ^= num2; num2 ^= num`; `num1 ^= num2` + + + +
+ +--- + +### converting a decimal to another base (`X`) + +
+ +* the **base** is a carry counting system with fixed digital symbols and rules. + +* you need to convert the integer part and the fractional part separately. + +* to convert the integer part, integer divide it by `X` until it reaches `0`, and record the remainder each time. + +* traversing the remainder in reverse order will give the representation in the base-X system. + +``` +50/2 = 25, 25/2 = 12, 12/2 = 6, 6/2 = 3, 3/2 = 1, 1/2 = 0 +50%2 = 0, 25%2 = 1, 12%2 = 0, 6%2 = 0, 3%2 = 1, 1%2 = 1 +--> 110010 +``` + +* to convert a fractional part, multiply the fractional part of the decimal number by `X `until it becomes `0`, and record the integer part each time. + +``` +0.6875x2 = 1.375 with integer 1, +0.375x2 = 0.75 with integer 0, +0.75x2 = 1.5 with integer 1, +0.5x2 = 1, with integer 1 +--> 0.1011 +``` + +
+ +```python +def convert_to_any_base(base: int, num: int) -> str: + + if num == 0: + return "0" + + n = abs(num) + result = "" + + while n: + result += str(n % base) + n //= base + + if num < 0: + result += '-' + + return result[::-1] +``` + +
+ + + +---- + +### hexadecimal + +
+ +* an integer of type int can be represented as a `32-bit` binary number. + +* since a one-digit hexadecimal number corresponds to a four-digit binary number, an integer of type int can also be represented as an `8-bit` hexadecimal number. + +
+ +```python +def convert_to_hex(num: int) -> str: + + hex_chars = "0123456789abcdef" + size = 32 + base = 16 + + if num == 0: + return "0" + + if num < 1: + num += 2**size + + result = "" + while num: + result += hex_chars[num % base] + num //= base + + return result[::-1] +``` + +
+ +---- + +### binary in computers + +
+ +* a single binary digit has two possible values, and a `k`-digit binary number can take `2^k` possible values. + +* `1-byte` number (`8` digits binary number) has `2^8` possible values. + +* in a `1-byte` signed integer, when the highest bit is `0`, the `1-byte` number ranges from `0` to `127` (`2^7 - 1`), when the highest bit is `1`, it ranges from `-128` to `-1` (*i.e.,* `-128` to `127`, which is `-2^7` to `2^7 -1`). + +* the binary representation of a number in a computer is called its **machine number**. it's a signed number, and the highest bit of the machine number is the sign bit `0`. + +* inverse code: for non-negative numbers, it's the same, for negative numbers, you flip every bit of the original code, except the sign bit. + * introducing the inverse code solves the problem of subtraction errors, but the issue of dual representation of `0` remains. +* complement code: is obtained from the inverse code, for non-negative numbers it's the same, for negative numbers it's obtained by adding `1` to the inverse code. for example, for `-10`, the original code is `10001010`, the inverse code is `11110101`, and the complement code is `11110110`. + * the complement code solves both the subtraction error and dual representation of the `0` problem (in complement code, there is no `-0`)., + +
+ +---- + +### bit operations + +
+ +- there are 6 types of bit operations: `AND`, `OR`, `XOR`, `negation`, `left shift`, and `right shift` (shift operations are further divided into the arithmetic shift and logical shift): + - `OR` and `AND`: symmetrical operations. + - `XOR`: when the corresponding bits of the two numbers are the same, the result is `1`. + - negation is unary: just flips the bit. + - left shift operation, `<<`, all binary bits are shifted to the left (the high bits are discarded, and the low bits are filled with 0). for left shift operations, arithmetic shift and logical shift are the same. + - right shift operation, `>>`, all binary bits are shift to the right (low bits are discarded). how the high bits get filled differs between arithmetic shift and logical shift: + - when shifting right arithmetically, the high bits are filled with the highest bit. + - when shifting right logically, the high bits are filled with `0`. + - for non-negative numbers, the arithmetic right shift and logical right shift are identical. + - for signed types, the right shift operation is an arithmetic right shift; for unsigned types, the right shift operation is a logical right shift. + - for languages without unsigned data type, the arithmetic right shift is `>>` and the logical shift is `>>>`. + +
+ +---- + +### relationship with multiplication/division + +
+ +* left shift corresponds to multiplication: shifting a number to the left by `k` bits is equivalent to multiplying the number by `2^k`. + * when the multiplier is not an integer power of `2`, the multiplier can be split into the sum of the integer power of two. + * for example, `a x 6` is equivalent to `(a << 2) + (a << 1)`. + * be careful against overflow. + +* arithmetic right-shift corresponds to the division: shifting a number to the right by k bits is equivalent to dividing the number by `2^k` for non-negative numbers. + * integer division is rounded to `0`, and the right shift operation is rounded down, which is also rounded to `0`. + * for negative numbers, integer division is rounded to `0`, while the right shift is rounded down -> so it's not equivalent to dividing a number by `2^k`. + +
+ +----- + +### properties of bitwise operations + +
+ +* idempotent: `a & a = a` + +* commutativity: `a & b = b &a` + +* associativity: `(a & b) & c = a * (b & c)` + +* distributive: `(a & b} | c = (a | c) & (b | c)` + +* de morgan's law: `~(a & b) = (~a) | (~b); ~ (a | b) = (~a) & (~b)` + +* 0 XOR: `a XOR 0 = a`; `a XOR a = 0` + +* `a & (a - 1)` changes the last 1 in the binary representation of a to 0. + +* ` a & (-a)` (equivalent to `a & (~(a - 1)`) keeps only the last 1 of the binary representation of a and sets the remaining 1s to 0. + + +
+ +---- + +### two's complement method + +
+ +* the complement is the number with respect to `2**n`: + +1. start with the equivalent positive number +2. invert (or flip) all bits, changing every `0` to `1`, and every `1` to `0` +3. add `1` to the entire inverted number, ignoring overflow + +
+ +--- + +### playing with bits + +
+ +```python +def count_ones(n: int) -> int: + + counter = 0 + + while n: + + if n & 1: + counter += 1 + + n >>= 1 + + return counter + +def set_bit(num, i): + mask = 1 << i + return bin( num | mask ) + +def update_bit(num, i, v): + mask = ~ (1 << i) + return bin( (num & mask) | (v << i) ) + +def count_bits_swapped(a, b): + count = 0 + m = a^b + while m: + count +=1 + m = m & (m-1) + return count + +def clear_bit(num, i): + mask = ~ (1 << i) # -0b10001 + return bin(num & mask) + +def swap_bit_in_place(a, b): + a = a^b + b = a^b + a = a^b + return a, b + +def find_how_many_1_in_a_binary(num): + + counter = 0 + while num: + if num & 1: + counter += 1 + num >>= 1 + return counter + +def reverse_bits(n: int) -> int: + + result, base = 0, 31 + while n: + result += (n & 1) << base + n >>= 1 + base -= 1 + + return result + +def get_sum(self, a: int, b: int) -> int: + + if a == -b: + return 0 + + if abs(a) > abs(b): + a, b = b, a + + if a < 0: + return - get_sum(-a, -b) + + while b: + + c = a & b + a, b = a ^ b, c << 1 + + return a +``` diff --git a/bit_operations/convert_any_base.py b/bit_operations/convert_any_base.py new file mode 100644 index 0000000..e24830d --- /dev/null +++ b/bit_operations/convert_any_base.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def convert_to_any_base(base: int, num: int) -> str: + + if num == 0: + return "0" + + n = abs(num) + result = "" + + while n: + result += str(n % base) + n //= base + + if num < 0: + result += '-' + + return result[::-1] diff --git a/bit_operations/convert_to_hex.py b/bit_operations/convert_to_hex.py new file mode 100644 index 0000000..0b25aec --- /dev/null +++ b/bit_operations/convert_to_hex.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def convert_to_hex(num: int) -> str: + + hex_chars = "0123456789abcdef" + size = 32 + base = 16 + + if num == 0: + return "0" + + if num < 1: + num += 2**size + + result = "" + while num: + result += hex_chars[num % base] + num //= base + + return result[::-1] diff --git a/bit_operations/count_1s.py b/bit_operations/count_1s.py new file mode 100644 index 0000000..b841a8e --- /dev/null +++ b/bit_operations/count_1s.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def count_ones(n: int) -> int: + + counter = 0 + + while n: + + if n & 1: + counter += 1 + + n >>= 1 + + return counter diff --git a/bit_operations/playing_with_bits.py b/bit_operations/playing_with_bits.py new file mode 100644 index 0000000..b03fa18 --- /dev/null +++ b/bit_operations/playing_with_bits.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def set_bit(num, i): + mask = 1 << i + return bin( num | mask ) + +def update_bit(num, i, v): + mask = ~ (1 << i) + return bin( (num & mask) | (v << i) ) + +def count_bits_swapped(a, b): + count = 0 + m = a^b + while m: + count +=1 + m = m & (m-1) + return count + +def clear_bit(num, i): + mask = ~ (1 << i) # -0b10001 + return bin(num & mask) + +def swap_bit_in_place(a, b): + a = a^b + b = a^b + a = a^b + return a, b + +def find_how_many_1_in_a_binary(num): + + counter = 0 + while num: + if num & 1: + counter += 1 + num >>= 1 + return counter + + +if __name__ == '__main__': + + binary_number = '10010000' + binary_number2 = '01011010' + integer_number = int(binary_number, 2) + integer_number2 = int(binary_number2, 2) + + print(f'Integer number: {integer_number}') + print(f'Binary number: {binary_number}') + print(f'\nUpdate bit: {update_bit(integer_number, 2, 1)}') + print(f'Set bit: {set_bit(integer_number, 2)}') + print(f'Clear bit: {clear_bit(integer_number, 4)}') + print(f'\nI: {integer_number}, I2: {integer_number2}') + print(f'B: {binary_number}, B2: {binary_number2}') + print(f'Count bits swapped: {count_bits_swapped(integer_number, integer_number2)}') + print(f'\nSwap bit in place: {swap_bit_in_place(integer_number, integer_number2)}') + print(f'Find how many 1 in a binary: {find_how_many_1_in_a_binary(integer_number)}') + \ No newline at end of file diff --git a/bit_operations/reverse_bits.py b/bit_operations/reverse_bits.py new file mode 100644 index 0000000..cf2984f --- /dev/null +++ b/bit_operations/reverse_bits.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def reverse_bits(n: int) -> int: + + result, base = 0, 31 + + while n: + result += (n & 1) << base + n >>= 1 + base -= 1 + + return result diff --git a/bit_operations/sum_with_bitwise.py b/bit_operations/sum_with_bitwise.py new file mode 100644 index 0000000..cb0b004 --- /dev/null +++ b/bit_operations/sum_with_bitwise.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def get_sum(self, a: int, b: int) -> int: + + if a == -b: + return 0 + + if abs(a) > abs(b): + a, b = b, a + + if a < 0: + return - get_sum(-a, -b) + + while b: + + c = a & b + a, b = a ^ b, c << 1 + + return a diff --git a/dynamic_programming/README.md b/dynamic_programming/README.md new file mode 100644 index 0000000..0398542 --- /dev/null +++ b/dynamic_programming/README.md @@ -0,0 +1,253 @@ +## dynamic programming + +
+ +* dynamic programming is the process of taking a recursive algorithm and cache overlapping problems (repeated calls). the runtime is given by the number of calls. + +* **top-down** (**memoization**): how can we divide the problem into sub-problems? + +* **bottom-up** (**tabulation**): solve for a simple case, then figure out for more elements. + + +
+ +--- + +### recursion + +
+ +* recursion is an approach to solving problems using a function that calls itself as a subroutine. every time the function calls itself, it reduces the problem into subproblems. the recursion calls continue until it reaches a point where the subproblem can be solved without further recursion. + +* a recursive function should have the following properties so it does not result in an infinite loop: + * one or more base cases (a terminating scenario that does not use recursion to produce an answer) + * a set of rules, also known as a recurrence relation, that reduces all other cases towards the base case. + +
+ +```python +def fib(n): + if n <= 1: + return n + return fib(n - 1) + fib(n - 2) +``` + +
+ +* there can be multiple places where the function may call itself. + +* any recursion problem can be solved iteratively and vice-versa. + +* the **master theorem** is an advanced technique of asymptotic analysis (time complexity) for many of the recursion algorithms that follow the pattern of divide-and-conquer. + +
+ + +#### vizualing the stack + +
+ +* to visualize how the stack operates during recursion calls, check the example below where we reverse a string: + +
+ +```python +def reverse(s): + if len(s) == 0: + return s + else: + return reverse(s[1:]) + s[0] +``` + +
+ + +#### tail recursion + +
+ +* tail recursion is a recursion where the recursive call is the final instruction in the recursion function. and there should be only one recursive call in the function. + +* tail recursion is exempted from the space overhead discussed above, ad it skips an entire chain of recursive calls returning and returns straight to the original caller (it does not need a call stack for all the recursive calls - instead of allocating new space on the stack, the system could simply reuse the space allocated earlier for this second recursion call). + +* when stack overflows, tail recursion might help. + +* some languages' compiler recognizes tail recursion pattern and optimizes their execution (e.g., C and C++, but not Java, Rust, or Python - although it's possible to implement ad-hoc). + +
+ +```python +def sum_non_tail_recursion(ls): + if len(ls) == 0: + return 0 + + # not a tail recursion because it does some computation after the recursive call returned + return ls[0] + sum_non_tail_recursion(ls[1:]) + + +def sum_tail_recursion(ls): + + def helper(ls, acc): + if len(ls) == 0: + return acc + + # this is a tail recursion because the final instruction is a recursive call + return helper(ls[1:], ls[0] + acc) + + return helper(ls, 0) +``` + +
+ + + +--- + +### memoization + +
+ +* memoization is an optimization technique that avoids recursion's duplicate calculations. + +* it's primarily used to speed up code by storing the intermediate results in a cache so that it can be reused later. + +* for example, a hash table can be used as a cache and should be passed along each subroutine call. + +
+ +```python +function dp(dp_state, memo_dict): + + if dp_state is the base cases + return things like 0 or null + + if dp_state in memo_dict + return memo_dict[dp_state] + + calculate dp(dp_state) from dp(other_state) + save dp_state and the result into memo_dict + +function answerToProblem(input) + return dp(start_state, empty_memo_dict) +``` + +
+ +* classic examples where memoization can be used are fibonacci and the "climbing stairs" problem: + +
+ +```python +def climb_stairs_memoization(n: int) -> int: + + memo = {} + + def helper(n: int, memo: dict[int, int]) -> int: + if n == 0 or n == 1: + return 1 + if n not in memo: + memo[n] = helper(n-1, memo) + helper(n-2, memo) + return memo[n] + + return helper(n, memo) +``` + +
+ +* another good example is calculating all possible subnodes in a tree: + +
+ +```python +class Node: + def __init__(self, val=0, left=None, right=None): + self.val = val + self.left = left + self.right = right + + +def all_possible_bst(start, end, memo): + + result = [] + if start > end: + return result + + if (start, end) in memo: + return memo[(start, end)] + + for i in range(start, end + 1): + left = all_possible_bst(start, i - 1, memo) + right = all_possible_bst(i + 1, end, memo) + + for l in left: + for r in right: + result.append(Node(i, l, r)) + + memo[(start, end)] = result + return result + + +def generate_trees(n): + + memo = {} + return all_possible_bst(1, n, memo) +``` + +
+ +---- + +### time complexity + +
+ +* the time complexity of a recursion algorithm is the product of the number of recursion invocations and the time complexity of the calculation, `R*O(s)`. + +* you can also look at the "execution tree", which is a tree that is used to denote the execution flow of a recursive function in particular. each node represents an invocation of the recursive function. therefore, the total number of nodes in the tree corresponds to the number of recursion calls during the execution. + * the execution tree of a recursive function would form a n-ary tree, with as the number of times recursion appears in the recurrence relation (for example, fibonacci would be a binary tree). + * in a full binary tree with n levels, the total number of nodes is `2**N - 1`, so `O(2**N)` would be the time complexity of the function. + * with memoization, fibonacci becomes `O(1)*N = O(N)`. + +
+ +---- + +### space complexity + +
+ +* there are mainly two parts of the space consumption that one should see in a recursive algorithm: + * **recursion related space**: refers to the memory cost that is incurred directly by the recursion, i.e. the stack to keep track of recursive function calls. in order to complete a recursive call, the system allocates some space in the stack to hold: the returning address of the function call, the parameters that are passed to the function call, the local variables within the function call. once the function call is done, the space is freed. for recursive algorithms, the function calls chain up successively until it reaches a base case, so the space used for each call is accumulated. overconsumption can cause stack overflow. + * **non-recursive related space**: refers to the memory that is not directly related to recursion, which includes the space (normally in heap) that is allocated for global variables. + +
+ + +--- + +### backtracking + +
+ +* backtracking is a general algorithm for finding solutions to some computation problems, which incrementally builds candidates to the solution and abandons a candidate ("backtracks") as soon as it determines that the candidate cannot lead to a valid solution. + +* you can imagine the procedure as the tree traversal. + +
+ +```python +def backtrack(candidate): + if find_solution(candidate): + output(candidate) + return + + for next in list_of_candidates: + + if is_valid(next_candidate): + place(next_candidate) + backtrack(next_candidate) + remove(next_candidate) +```` + +
+ diff --git a/dynamic_programming/bst_all_subnodes.py b/dynamic_programming/bst_all_subnodes.py new file mode 100644 index 0000000..4ac8255 --- /dev/null +++ b/dynamic_programming/bst_all_subnodes.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, val=0, left=None, right=None): + self.val = val + self.left = left + self.right = right + + +def all_possible_bst(start, end, memo): + + result = [] + if start > end: + return result + + if (start, end) in memo: + return memo[(start, end)] + + for i in range(start, end + 1): + left = all_possible_bst(start, i - 1, memo) + right = all_possible_bst(i + 1, end, memo) + + for l in left: + for r in right: + result.append(Node(i, l, r)) + + memo[(start, end)] = result + return result + + +def generate_trees(n): + + memo = {} + return all_possible_bst(1, n, memo) diff --git a/dynamic_programming/climbing_stairs.py b/dynamic_programming/climbing_stairs.py new file mode 100644 index 0000000..c699acd --- /dev/null +++ b/dynamic_programming/climbing_stairs.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +''' +You are climbing a staircase. It takes n steps to reach the top. +Each time you can either climb 1 or 2 steps. +In how many distinct ways can you climb to the top? +''' + + +def climb_stairs_o2n(n: int) -> int: + + if n == 0 or n == 1: + return 1 + return climb_stairs_o2n(n - 1) + climb_stairs_o2n(n - 2) + + +def climb_stairs_memoization(n: int) -> int: + + memo = {} + + def helper(n: int, memo: dict[int, int]) -> int: + if n == 0 or n == 1: + return 1 + if n not in memo: + memo[n] = helper(n - 1, memo) + helper(n - 2, memo) + return memo[n] + + return helper(n, memo) + + +def climb_stairs_optimized(n: int) -> int: + + if n == 0 or n == 1: + return 1 + prev, curr = 1, 1 + + for i in range(2, n + 1): + temp = curr + curr = prev + curr + prev = temp + + return curr + + +def climb_stairs_tabulation(n: int) -> int: + + if n == 0 or n == 1: + return 1 + + dp = [0] * (n + 1) + dp[0] = dp[1] = 1 + + for i in range(2, n + 1): + dp[i] = dp[i - 1] + dp[i - 2] + + return dp[n] diff --git a/graphs/README.md b/graphs/README.md new file mode 100644 index 0000000..e12cea3 --- /dev/null +++ b/graphs/README.md @@ -0,0 +1,339 @@ +## graphs + +
+ +* graph is a non-linear data structure consisting of vertices and edges. + + +* graphs can be represented by adjacent matrices, adjacent lists, and hash table of hash tables. + + +* in **undirected graphs**, the edges between any two vertices do not have a direction, indicating a two-way relationship. + + +* in **directed graphs**, the edges between any two vertices are directional. + + +* in **weighted graphs**, each edge has an associated weight. if the sum of the weights of all edges of a cycle is a negative values, it's a negative weight cycle. + + +* the **degree of a vertex** is the number of edges connecting the vertex. in directed, graphs, if the **in-degree** of a vertex is `d`, there are **d** directional edges incident to the vertex (and similarly, **out-degree** from the vertex). + + +* with `|V|` the number of vertices and `|E|` is the number of edges, search in a graph (either bfs of dfs) is `O(|V| + |E|)`. + +
+ +--- + +### traversals + +
+ +#### breath first search + +
+ +* check **[../trees/#breath-first-search](https://github.com/go-outside-labs/master-algorithms-py/blob/master/trees/README.md#tree-traversal-depth-first-search)** + +
+ +```python +def bfs(matrix): + + if not matrix: + return [] + + rows, cols = len(matrix), len(matrix[0]) + visited = set() + directions = ((0, 1), (0, -1), (1, 0), (-1, 0)) + + def traverse(i, j): + queue = deque([(i, j)]) + while queue: + curr_i, curr_j = queue.popleft() + if (curr_i, curr_j) not in visited: + visited.add((curr_i, curr_j)) + + for direction in directions: + next_i, next_j = curr_i + direction[0], curr_j + direction[1] + if 0 <= next_i < rows and 0 <= next_j < cols: + + queue.append((next_i, next_j)) + + for i in range(rows): + for j in range(cols): + traverse(i, j) +``` + +
+ +* or as a class: + +
+ +```python + +from collections import deque + + +class Graph: + + def __init__(self, edges, n): + + self.adj_list = [[] for _ in range(n)] + + for (src, dest) in edges: + self.adj_list[src].append(dest) + self.adj_list[dest].append(src) + + +def bfs(graph, v, discovered): + + queue = deque(v) + discovered[v] = True + + while queue: + + v = queue.popleft() + print(v, end=' ') + + for u in graph.adj_list[v]: + if not discovered[u]: + discovered[u] = True + queue.append(u) + + +def recursive_bfs(graph, queue, discovered): + + if not queue: + return + + v = queue.popleft() + print(v, end=' ') + + for u in graph.adj_list[v]: + if not discovered[u]: + discovered[u] = True + queue.append(u) + + recursive_bfs(graph, queue, discovered) +``` + +
+ +---- + +#### depth first search + +
+ +* and **[../trees/#depth-first-search](https://github.com/go-outside-labs/master-algorithms-py/blob/master/trees/README.md#tree-traversal-breath-first-search-level-order)** + +
+ +```python +def dfs(matrix): + if not matrix: + return [] + + rows, cols = len(matrix), len(matrix[0]) + visited = set() + directions = ((0, 1), (0, -1), (1, 0), (-1, 0)) + + def traverse(i, j): + if (i, j) in visited: + return + + visited.add((i, j)) + for direction in directions: + next_i, next_j = i + direction[0], j + direction[1] + if 0 <= next_i < rows and 0 <= next_j < cols: + traverse(next_i, next_j) + + for i in range(rows): + for j in range(cols): + traverse(i, j) +``` + +
+ +* or as a class: + +
+ +```python +from collections import deque + +class Graph: + + def __init__(self, edges, n): + + self.adj_list = [[] for _ in range(n)] + + for (src, dest) in edges: + self.adj_list[src].append(dest) + self.adj_list[dest].append(src) + + +def dfs(graph, v, discovered): + + discovered[v] = True + print(v, end=' ') + + for u in graph.adj_list[v]: + if not discovered[u]: + dfs(graph, u, discovered) + + + +def iterative_dfs(graph, v, discovered): + + stack = [v] + + while stack: + + v = stack.pop() + + if discovered[v]: + continue + + discovered[v] = True + print(v, end=' ') + + adj_list = graph.adjList[v] + for i in reversed(range(len(adj_list))): + u = adj_list[i] + if not discovered[u]: + stack.append(u) +``` + +
+ +--- + +### matrix bfs and dfs + +
+ +* given an `m x n` grid rooms initialized with these three possible values: + * -1 A wall or an obstacle. + * 0 A gate. + * `INF` Infinity means an empty room (`2^31 - 1 = 2147483647` to represent `INF`) + +* fill the empty room with the distance to its nearest gate. if it is impossible to reach a gate, it should be filled with `INF`. + +
+ +```python + + +def matrix_bfs(rooms) -> None: + + m = len(rooms) + if m == 0: + return rooms + n = len(rooms[0]) + + GATE = 0 + EMPTY = 2147483647 + DIRECTIONS = ((1, 0), (-1, 0), (0, 1), (0, -1)) + + queue = collections.deque() + + for i in range(m): + for j in range(n): + + if rooms[i][j] == GATE: + q.append((i, j)) + + while queue: + + row, col = queue.popleft() + + for (x, y) in DIRECTIONS: + + r = row + x + c = col + y + + if (r < 0) or (c < 0) or (r >= m) or (c >= n) or rooms[r][c] != EMPTY: + continue + + rooms[r][c] = rooms[row][col] + 1 + queue.append((r, c)) +``` + +
+ + +* given an `m x n` 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. + +
+ +```python +def num_island_dfs(grid) -> int: + + LAND = '1' + answer = 0 + + def dfs(row, col): + + if row < 0 or row >= len(grid) or col < 0 or col >= len(grid[0]) or grid[row][col] != LAND: + return + + grid[row][col] = 'x' + dfs(row + 1, col) + dfs(row - 1, col) + dfs(row, col - 1) + dfs(row, col + 1) + + for i in range(len(grid)): + for j in range(len(grid[0])): + if grid[i][j] == LAND: + answer += 1 + dfs(i, j) + + return answer +``` + +
+ +* and a solution for the problem above, using bfs: + +
+ +```python +def num_island_bfs(grid) -> int: + + LAND = '1' + answer = 0 + queue = collections.deque() + + def bfs(row, col, queue): + + delta = [(1, 0), (0, 1), (-1, 0), (0, -1)] + + while queue: + x, y = queue.popleft() + + for dx, dy in delta: + + px, py = x + dx, y + dy + if px < 0 or px >= len(grid) or py < 0 or py >= len(grid[0]) or grid[px][py] != LAND: + continue + + grid[px][py] = 'x' + queue.append((px, py)) + + + for i in range(len(grid)): + for j in range(len(grid[0])): + + if grid[i][j] == LAND: + answer += 1 + queue.append((i, j)) + bfs(i, j, queue) + + + return answer +``` diff --git a/graphs/bfs.py b/graphs/bfs.py new file mode 100644 index 0000000..edafb4c --- /dev/null +++ b/graphs/bfs.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +from collections import deque + + +class Graph: + + def __init__(self, edges, n): + + self.adj_list = [[] for _ in range(n)] + + for (src, dest) in edges: + self.adj_list[src].append(dest) + self.adj_list[dest].append(src) + + +def bfs(graph, v, discovered): + + queue = deque(v) + discovered[v] = True + + while queue: + + v = queue.popleft() + print(v, end=' ') + + for u in graph.adj_list[v]: + if not discovered[u]: + discovered[u] = True + queue.append(u) + + +def recursive_bfs(graph, queue, discovered): + + if not queue: + return + + v = queue.popleft() + print(v, end=' ') + + for u in graph.adj_list[v]: + if not discovered[u]: + discovered[u] = True + queue.append(u) + + recursive_bfs(graph, queue, discovered) + diff --git a/graphs/dfs.py b/graphs/dfs.py new file mode 100644 index 0000000..a65a85b --- /dev/null +++ b/graphs/dfs.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +from collections import deque + +class Graph: + + def __init__(self, edges, n): + + self.adj_list = [[] for _ in range(n)] + + for (src, dest) in edges: + self.adj_list[src].append(dest) + self.adj_list[dest].append(src) + + +def dfs(graph, v, discovered): + + discovered[v] = True + print(v, end=' ') + + for u in graph.adj_list[v]: + if not discovered[u]: # + dfs(graph, u, discovered) + + + +def iterative_dfs(graph, v, discovered): + + stack = [v] + + while stack: + + v = stack.pop() + + if discovered[v]: + continue + + discovered[v] = True + print(v, end=' ') + + adj_list = graph.adjList[v] + for i in reversed(range(len(adj_list))): + u = adj_list[i] + if not discovered[u]: + stack.append(u) + diff --git a/graphs/dijkstra_adj_matrix.py b/graphs/dijkstra_adj_matrix.py new file mode 100644 index 0000000..732e9c9 --- /dev/null +++ b/graphs/dijkstra_adj_matrix.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +# dijkstra's single source shortest path algorithm +# with adjacency matrix representation + +import sys + + +class Graph(): + + def __init__(self, vertices): + + self.V = vertices + self.graph = [[0 for col in range(vertices)] for row in range(vertices)] + + def print_solution(self, dist): + + print("Vertex \tDistance from Source") + for node in range(self.V): + print(node, "\t", dist[node]) + + def min_distance(self, dist, sset): + + # minimum distance for next node + min_ = sys.maxsize + + # search not nearest vertex not in the shortest path tree + for u in range(self.V): + if dist[u] < min_ and sset[u] == False: + min_ = dist[u] + min_index = u + + return min_index + + + def dijkstra(self, src): + + dist = [sys.maxsize] * self.V + dist[src] = 0 + sset = [False] * self.V + + for c in range(self.V): + x = self.min_distance(dist, sset) + sset[x] = True + + for y in range(self.V): + if self.graph[x][y] > 0 and \ + sset[y] == False and \ + dist[y] > dist[x] + self.graph[x][y]: + dist[y] = dist[x] + self.graph[x][y] + + self.print_solution(dist) + + +if __name__ == "__main__": + g = Graph(9) + g.graph = [ [0, 4, 0, 0, 0, 0, 0, 8, 0], + [4, 0, 8, 0, 0, 0, 0, 11, 0], + [0, 8, 0, 7, 0, 4, 0, 0, 2], + [0, 0, 7, 0, 9, 14, 0, 0, 0], + [0, 0, 0, 9, 0, 10, 0, 0, 0], + [0, 0, 4, 14, 10, 0, 2, 0, 0], + [0, 0, 0, 0, 0, 2, 0, 1, 6], + [8, 11, 0, 0, 0, 0, 1, 0, 7], + [0, 0, 2, 0, 0, 0, 6, 7, 0] + ] + + g.dijkstra(0) diff --git a/graphs/matrix_bfs.py b/graphs/matrix_bfs.py new file mode 100644 index 0000000..edf4737 --- /dev/null +++ b/graphs/matrix_bfs.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def matrix_bfs(rooms) -> None: + + m = len(rooms) + if m == 0: + return rooms + n = len(rooms[0]) + + GATE = 0 + EMPTY = 2147483647 + DIRECTIONS = ((1, 0), (-1, 0), (0, 1), (0, -1)) + + queue = collections.deque() + + for i in range(m): + for j in range(n): + + if rooms[i][j] == GATE: + q.append((i, j)) + + while queue: + + row, col = queue.popleft() + + for (x, y) in DIRECTIONS: + + r = row + x + c = col + y + + if (r < 0) or (c < 0) or (r >= m) or (c >= n) or rooms[r][c] != EMPTY: + continue + + rooms[r][c] = rooms[row][col] + 1 + queue.append((r, c)) diff --git a/graphs/matrix_dfs_and_bfs.py b/graphs/matrix_dfs_and_bfs.py new file mode 100644 index 0000000..f85a251 --- /dev/null +++ b/graphs/matrix_dfs_and_bfs.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def num_island_dfs(grid) -> int: + + LAND = '1' + answer = 0 + + def dfs(row, col): + + if row < 0 or row >= len(grid) or col < 0 or col >= len(grid[0]) or grid[row][col] != LAND: + return + + grid[row][col] = 'x' + dfs(row + 1, col) + dfs(row - 1, col) + dfs(row, col - 1) + dfs(row, col + 1) + + for i in range(len(grid)): + for j in range(len(grid[0])): + if grid[i][j] == LAND: + answer += 1 + dfs(i, j) + + return answer + + +def num_island_bfs(grid) -> int: + + LAND = '1' + answer = 0 + queue = collections.deque() + + def bfs(row, col, queue): + + delta = [(1, 0), (0, 1), (-1, 0), (0, -1)] + + while queue: + x, y = queue.popleft() + + for dx, dy in delta: + + px, py = x + dx, y + dy + if px < 0 or px >= len(grid) or py < 0 or py >= len(grid[0]) or grid[px][py] != LAND: + continue + + grid[px][py] = 'x' + queue.append((px, py)) + + + for i in range(len(grid)): + for j in range(len(grid[0])): + + if grid[i][j] == LAND: + answer += 1 + queue.append((i, j)) + bfs(i, j, queue) + + + return answer diff --git a/hash_objects/README.md b/hash_objects/README.md new file mode 100644 index 0000000..dbb0bc4 --- /dev/null +++ b/hash_objects/README.md @@ -0,0 +1,298 @@ +## hash objects + + +
+ +* hash tables (also known as hash maps) are data structure that organizes data using hash functions, in order to support quick insertion and search (map keys to buckets). + +
+ + + +

+ +

+ + +
+ +--- + +### collision + +
+ +* ideally, a perfect hash function will be a 1-1 mapping between the key and the buckets. however, in most cases, a hash function is not perfect and there is a tradeoff between the amount of buckets and the capacity of a bucket. if the hash function is not a 1-1 mapping, collisions must be handled: + - how to organize the values in the same bucket? + - what if too many values are assigned to the same bucket? + - how to search for a target value in a specific bucket? + +* popular collision techniques are: + - separate chaining: a linked list is used for each value, so that it stores all the collided items. + - open addressing: all entry records are stored in the bucket array itself. when a new entry has to be inserted, the buckets are examined, starting with the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found. + + +
+ +---- + +### keys + +
+ +* when the order of each element in the string/array doesn't matter, you can use the sorted string/array to calculate a key. + +* if you only care about the offset of each value, you can use it as the key. + +* in a tree, you might want to directly use the `Node()` class as key sometimes, but in general, the serialization of the subtree might be a better idea. + +* in a matrix, you might want to use the row index or the column index as key. sometimes you might want to aggregate the values in the same diagonal line. + +
+ +--- + +### implementing a hash set + +
+ +* the difference between a hash set and a hash map is that the set can never have repeated elements. + +* to implement a hash set data structure, you need to implement: + - a hash function (to assign an address to store a given value), and + - a collision handling (since the nature of a hash function is to map a value from a space A to a corresponding smaller space B). + + +* overall, there are several strategies to resolve the collisions: + - separate chaining: for value with the same hash key, we keep them in a bucket, and each bucket is independent of each other. + - open addressing: whenever there is a collision, we keep on probing the main space with certain strategy until a free slot is found. + - 2-choices hashing: we use two hash functions rather than one, and pick the generated address with fewer collisions. + + +* if we were to implement separate chaining, the primary storage underneath a hashset is a continuous memory as array, where each element in this array corresponds to a bucket that stores the actual values. + * given a value, first we generate a key for the value via the hash function (the generated key serves as the index to locate the bucket). + * once the bucket is located, we then perform the desired operation on the bucket (such as add, remove, and contain). + * use a prime number as the base of the module to reduce collisions. + +
+ +```python +class HashSet: + + def __init__(self, size): + self.size = size + self.bucket = [Bucket() for _ in range(self.size)] + + def _get_hash_key(self, key): + return key % self.size + + def add(self, element: int): + bucket_index = self._get_hash_key(element) + self.bucket[bucket_index].insert(element) + + def remove(self, element: int)L + bucket_index = self._get_hash_key(element) + self.bucket[bucket_index].delete(element) + + def contains(self, element: int: + bucket_index = self._get_hash_key(element) + return self.bucket[bucket_index].exists(element) +```` + +
+ + +#### buckets as linked lists + +
+ +* a good choice for buckets are linked lists, as their time complexity for `insert` and `delete` is constant (once the position to be updated is located). + * you just need to be sure you never insert repeated elements. + +* time complexity for search is `O(N/K)` where `N` is the number of all possible values and `K` is the number of predefined buckets (the average size of bucket is `N/K`). + +* space complexity is `O(K+M)`, where `K` is the number of predefined buckets, and `M` is the number of unique values that have been inserted in the HashSet. + +* lastly, to optimize search, we could maintain the buckets as sorted lists (and obtain `O(log(N))` time complexity for the lookup operation). + * however, `insert` and `delete` are linear time (as elements would need to be shifted). + +
+ +```python +class Node: + def __init__(self, value=None, next=None): + self.value = value + self.next = next + + +class Bucket: + def __init__(self): + self.head = Node(0) + + def insert(self, value): + if not self.exists(value): + self.head.next = Node(value, self.head.next) + else: + print(f'node {value} already exists') + + def delete(self, value): + prev = self.head + current = self.head.next + while current is not None: + if current.value == value: + prev.next = current.next + return True + prev = current + current = current.next + return False + + def exists(self, value): + current = self.head.next + while current is not None: + if current.value == value: + return True + current = current.next + return False +``` + + +
+ +#### buckets as binary search trees + +
+ +* another option for a bucket is a binary search tree, with `O(log(N))` time complexity for search, insert, and delete. in addition, bst can not hold repeated elements, just like sets. + +* time complexity for search is `O(log(N/K)`, where `N` is the number of all possible values and `K` is the number of predefined buckets. + +* space complexity is `O(K+M)` where `K` is the number of predefined buckets, and `M` is the number of unique values in the hash set. + +
+ +```python +class Node: + def __init__(self, value=None): + self.val = value + self.left = None + self.right = None + + +class Bucket: + def __init__(self): + self.tree = BSTree() + + def insert(self, value): + self.tree.root = self.tree.insert(self.tree.root, value) + + def delete(self, value): + self.tree.root = self.tree.delete(self.tree.root, value) + + def exists(self, value): + return (self.tree.search(self.tree.root, value) is not None) + + +class BSTree(): + def __init__(self): + self.root = None + + def search(self, root, value) -> Node: + if root is None or value == root.val: + return root + + return self.search(root.left, value) if val < root.value \ + else self.search(root.right, value) + + def insert(self, root, value) -> Node: + if not root: + return Node(value) + + if value > root.val: + root.right = self.insert(root.right, value) + elif value == root.val: + return root + else: + root.left = self.insert(root.left, value) + + def successor(self, root): + # one step right and then all left + root = root.right + while root.left: + root = root.left + return root.value + + def predecessor(self, root): + # one step left and then always right + root = root.left + while root.right: + root = root.right + return root.value + + def delete(self, root, key) -> Node: + if not root: + return None + + if key > root.val: + root.right = self.delete(root.right, key) + + elif key < root.val: + root.left = self.delete(root.left, key) + + else: + if not (root.left or root.right): + root = None + elif root.right: + root.val = self.sucessor(root) + root.right = self.delete(root.right, root.val) + else: + root.val = self.predecessor(root) + root.left = self.delete(root.left, root.val) + + return root +``` + +
+ +---- + +### implementing a hash map + +
+ +* same as before, we need to tackle two main issues: hash function design and collision handling. + +* a good approach is using a module function with an array or linked list. at this time, there is no constraint for repeated numbers. + +
+ +```python +class Bucket: + + def __init__(self): + self.bucket = [] + + def get(self, key): + for (k, v) in self.bucket: + if k == key: + return v + return -1 + + def put(self, key, value): + found = False + for i, k in enumerate(self.bucket): + if key == k[0]: + self.bucket[i] = (key, value) + found = True + break + if not found: + self.bucket.append((key, value)) + + def remove(self, key): + for i, k in enumerate(self.bucket): + if key == k[0]: + del self.bucket[i] +``` +
+ +* del is an `O(N)` operation, as we would copy all the `i` elements. to make it `O(1)` we could swap the element we want to remove with the last element in the bucket. + diff --git a/hash_objects/hash_map_array.py b/hash_objects/hash_map_array.py new file mode 100644 index 0000000..6508815 --- /dev/null +++ b/hash_objects/hash_map_array.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Bucket: + + def __init__(self): + self.bucket = [] + + def get(self, key): + for (k, v) in self.bucket: + if k == key: + return v + return -1 + + def put(self, key, value): + found = False + for i, k in enumerate(self.bucket): + if key == k[0]: + self.bucket[i] = (key, value) + found = True + break + if not found: + self.bucket.append((key, value)) + + def remove(self, key): + for i, k in enumerate(self.bucket): + if key == k[0]: + # del is an O(N) operation, as we would copy all the i: elements + # to make it O(1) we could swap the element we want to remove + # with the last element in the bucket + del self.bucket[i] + + +class HashMap: + + def __init__(self, size): + self.size = size + self.table = [Bucket() for _ in range(self.size)] + + def _get_hash_key(self, key): + return key % self.size + + def put(self, key: int, value: int): + hash_key = self._get_hash_key(key) + self.table[hash_key].put(key, value) + + def get(self, key: int): + hash_key = self._get_hash_key(key) + return self.table[hash_key].get(key) + + def remove(self, key: int): + hash_key = self._get_hash_key(key) + self.table[hash_key].remove(key) + + + diff --git a/hash_objects/hash_set_bst.py b/hash_objects/hash_set_bst.py new file mode 100644 index 0000000..08cb8b4 --- /dev/null +++ b/hash_objects/hash_set_bst.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class HashSet: + + def __init__(self, size): + self.size = size + self.bucket = [Bucket() for _ in range(self.size)] + + def _get_hash_key(self, key): + return key % self.size + + def add(self, element: int) -> None: + bucket_index = self._get_hash_key(element) + self.bucket[bucket_index].insert(element) + + def remove(self, element: int) -> None: + bucket_index = self._get_hash_key(element) + self.bucket[bucket_index].delete(element) + + def contains(self, element: int) -> bool: + bucket_index = self._get_hash_key(element) + return self.bucket[bucket_index].exists(element) + + +class Node: + def __init__(self, value=None): + self.val = value + self.left = None + self.right = None + + +class Bucket: + def __init__(self): + self.tree = BSTree() + + def insert(self, value): + self.tree.root = self.tree.insert(self.tree.root, value) + + def delete(self, value): + self.tree.root = self.tree.delete(self.tree.root, value) + + def exists(self, value): + return (self.tree.search(self.tree.root, value) is not None) + + +class BSTree(): + def __init__(self): + self.root = None + + def search(self, root, value) -> Node: + if root is None or value == root.val: + return root + + return self.search(root.left, value) if val < root.value \ + else self.search(root.right, value) + + def insert(self, root, value) -> Node: + if not root: + return Node(value) + + if value > root.val: + root.right = self.insert(root.right, value) + elif value == root.val: + return root + else: + root.left = self.insert(root.left, value) + + def successor(self, root): + # one step right and then all left + root = root.right + while root.left: + root = root.left + return root.value + + def predecessor(self, root): + # one step left and then always right + root = root.left + while root.right: + root = root.right + return root.value + + def delete(self, root, key) -> Node: + if not root: + return None + + if key > root.val: + root.right = self.delete(root.right, key) + + elif key < root.val: + root.left = self.delete(root.left, key) + + else: + if not (root.left or root.right): + root = None + elif root.right: + root.val = self.sucessor(root) + root.right = self.delete(root.right, root.val) + else: + root.val = self.predecessor(root) + root.left = self.delete(root.left, root.val) + + return root + diff --git a/hash_objects/hash_set_linked_list.py b/hash_objects/hash_set_linked_list.py new file mode 100644 index 0000000..823bc0d --- /dev/null +++ b/hash_objects/hash_set_linked_list.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class HashSet: + + def __init__(self, size): + self.size = size + self.bucket = [Bucket() for _ in range(self.size)] + + def _get_hash_key(self, key): + return key % self.size + + def add(self, element: int) -> None: + bucket_index = self._get_hash_key(element) + self.bucket[bucket_index].insert(element) + + def remove(self, element: int) -> None: + bucket_index = self._get_hash_key(element) + self.bucket[bucket_index].delete(element) + + def contains(self, element: int) -> bool: + bucket_index = self._get_hash_key(element) + return self.bucket[bucket_index].exists(element) + + +class Node: + def __init__(self, value=None, next=None): + self.value = value + self.next = next + + +class Bucket: + def __init__(self): + self.head = Node(0) + + def insert(self, value): + if not self.exists(value): + self.head.next = Node(value, self.head.next) + else: + print(f'node {value} already exists') + + def delete(self, value): + prev = self.head + current = self.head.next + while current is not None: + if current.value == value: + prev.next = current.next + return True + prev = current + current = current.next + return False + + def exists(self, value): + current = self.head.next + while current is not None: + if current.value == value: + return True + current = current.next + return False + diff --git a/heaps/README.md b/heaps/README.md new file mode 100644 index 0000000..63106d7 --- /dev/null +++ b/heaps/README.md @@ -0,0 +1,518 @@ +## heaps + +
+ +

+ +

+ + + +
+ +* heap is a data structure capable of giving you the smallest (or the largest) element in constant time, while adding or removing the smallest (or the largest) element in logarithmic time. + +* a heap is like a binary tree with these properties: + * it must have all of **its nodes in a specific order**, and + * its shape must be **complete** (all the levels of the tree must be completely filled except maybe for the last one and the last level must have the left-most nodes filled, always). + * a max heap's **root node must** have all its children either **greater than or equal** to its children. + * a min heap is the opposite. duplicate values are allowed. + +* heaps can be represented with linked lists, queues (arrays), or binary trees. + +* in the case of an array heap: + * the parent node index is given by `n / 2` + * the left children index is `2 * n` + * the right children index is `2 * n + 1` + * a node is a leaf when its index `> n / 2` + +* common applications of heap are: sort (heap sort), getting the top-k elements, and finding the kth element. + +* in python you can use `heapq.heapify(array)` with `heapq.heappush(array, value)` and `heapq.heappop()`. + +
+ +```python +class Heap: + + def __init__(self): + + self.heap = [] + + def heapify(self, n, i): + + largest = i + left_children = 2 * i + 1 + right_children = 2 * i + 2 + + if left_children < n and self.heap[i] < self.heap[left_children]: + largest = left_children + + if right_children < n and self.heap[largest] < self.heap[right_children]: + largest = right_children + + if largest != i: + self.heap[i], self.heap[largest] = self.heap[largest], self.heap[i] + self.heapify(n, largest) + + + def insert(self, num): + + size = len(self.heap) + + if size == 0: + self.heap.append(num) + + else: + self.heap.append(num) + for i in range((size // 2) - 1, -1, -1): + self.heapify(size, i) + + + def delete_node(self, num): + + size = len(self.heap) + + i = 0 + for i in range(size): + if num == self.heap[i]: + break + + self.heap[i], self.heap[size - 1] = self.heap[size - 1], self.heap[i] + + self.heap.remove(size - 1) + + for i in range((len(self.heap) // 2) - 1, -1, -1): + self.heapify(len(self.heap), i) +``` + +
+ +--- + +### heapify + +
+ +* it's cheaper to heapify an array of data (`O(N)`) than create an empty heap and inserting each element (`O(N log(N))`). + * heapify means create a binary tree and then comparing each nodes with their children (and swapping when necessary). + * parents node can simply exchange with their smallest child (so the max number of exchanges is `N/2`) and leaves are left out. + +* python's built-in heap differs from the standard implementation of a heap in two ways: + * firstly, it uses zero-based indexing, so it stores the root node at index zero instead of the size of the heap. + * secondly, the built-in module does not offer a direct way to create a max heap, instead, we must modify the values of each element when inserting in the heap, and when removing it from the heap. + +
+ +```python +import heapq + +min_heap = [3,1,2] +heapq.heapify(min_heap) + +max_heap = [-x for x in min_heap] +heapq.heapify(max_heap) + +heapq.heappush(min_heap, 5) +heapq.heappush(min_heap, -5) + +min_elem = min_heap[0] +max_elem = -1 * max_heap[0 + +heapq.heappop(min_heap) +heapq.heappop(max_heap) + +size_min_heap = len(min_heap) +size_max_heap = len(max_heap) +``` + +
+ +---- + +### priority queues + +
+ +* a priority queue is an abstract data type with the following properties: + 1. every item has a priority (usually an integer). + 2. an item with a high priority is dequeued before an item with low priority. + 3. two items with an equal priority are dequeued based on their order in the queue. + +* priority queues can be implemented with a stack, queue, or linked list data structures. + +
+ +--- + +### min heaps + +
+ +* a **min heap** is a complete binary tree where each node is smaller than its children (the root is the min element). + +* `insert`: + - insert the element at the bottom, by finding the most rightmost node and checking its children: if left is empty, insert there, otherwise, insert on right. + - then compare this node to each parent, exchanging them until the tree's properties are correct. + +* `extract_min`: + - first, remove/return the top and then replace the tree's top with its latest element (the bottom-most rightmost). + - then bubble down, swapping it with one of its children until the min-heap is properly restored + - there is no need for order between right and left, so this operation would only take `O(log N)` runtime. + +* the code below is an example of an ad-hoc heap class in python. + +
+ +```python +class MinHeap: + + def __init__(self, size): + + self.heapsize = size + self.minheap = [0] * (size + 1) + self.realsize = 0 + + def add(self, element): + + if self.realsize + 1 > self.heapsize: + print("Too many elements!") + return False + + self.realsize += 1 + self.minheap[self.realsize] = element + + index = self.realsize + parent = index // 2 + + while self.minheap[index] < self.minheap[parent] and index > 1: + + self.minheap[parent], self.minheap[index] = self.minheap[index], self.minheap[parent] + index = parent + parent = index // 2 + + def peek(self): + + return self.minheap[1] + + def pop(self): + + if self.realsize < 1: + print("Heap is empty.") + return False + + else: + remove_element = self.minheap[1] + self.minheap[1] = self.minheap[self.realsize] + self.realsize -= 1 + index = 1 + + while index <= self.realsize // 2: + + left_children = index * 2 + right_children = (index * 2) + 1 + + if self.minheap[index] > self.minheap[left_children] or \ + self.minheap[index] > self.minheap[right_children]: + + if self.minheap[left_children] < self.minheap[right_children]: + + self.minheap[left_children], self.minheap[index] = self.minheap[index], self.minheap[left_children] + index = left_children + + else: + + self.minheap[right_children], self.minheap[index] = self.minheap[index], self.minheap[right_children] + index = right_children + else: + break + + return remove_element + + def size(self): + return self.realsize + + def __str__(self): + return str(self.minheap[1 : self.realsize + 1]) +``` + +
+ +--- + +### max heaps + +
+ +* a **max heap** is a complete binary tree where each node is larger than its children (the root is the max element). + +* `insert`: + * insert the element at the bottom, at the leftmost node. + * then compare the node to each parent, exchanging them until the tree's properties are correct. + +* `extract_max`: + * remove/return the top and then replace the tree's top with its bottom rightmost element. + * swap up until the max element is on the top. + +* the code below is an example of a max heap class built in python: + +
+ +```python +class MaxHeap: + def __init__(self, heapsize): + + self.heapsize = heapsize + self.maxheap = [0] * (heapsize + 1) + self.realsize = 0 + + def add(self, element): + + self.realsize += 1 + if self.realsize > self.heapsize: + print("Too many elements!") + self.realsize -= 1 + return False + + self.maxheap[self.realsize] = element + index = self.realsize + parent = index // 2 + + while self.maxheap[index] > self.maxheap[parent] and index > 1: + self.maxheap[parent], self.maxheap[index] = self.maxheap[index], self.maxheap[parent] + index = parent + parent = index // 2 + + def peek(self): + + return self.maxheap[1] + + def pop(self): + + if self.realsize < 1: + print("Heap is empty.") + return False + else: + remove_element = self.maxheap[1] + self.maxheap[1] = self.maxheap[self.realsize] + self.realsize -= 1 + index = 1 + + while (index <= self.realsize // 2): + + left_children = index * 2 + right_children = (index * 2) + 1 + + if (self.maxheap[index] < self.maxheap[left_children] or self.maxheap[index] < self.maxheap[right_children]): + if self.maxheap[left_children] > self.maxheap[right_children]: + self.maxheap[left_children], self.maxheap[index] = self.maxheap[index], self.maxheap[left_children] + index = left_children + else: + self.maxheap[right_children], self.maxheap[index] = self.maxheap[index], self.maxheap[right_children] + index = right_children + else: + break + return remove_element + + def size(self): + return self.realsize + + def __str__(self): + return str(self.maxheap[1 : self.realsize + 1]) +``` + +
+ +--- + + +### heap sort + +
+ + +* the core concept of the heap sort involves constructing a heap from our input and then repeatedly removing the min/max element to sort the array. + +* the key idea for in-place heap sort involves a balance of these two ideas: + - building a heap from an unsorted array through a "bottom-up heapification" process, and + - using the heap to sort the input array + +* heapsort traditionally uses a max-heap to sort the array, although a min-heap also works. + +* this is not a stable sort. + +
+ +```python +def heap_sort(self, array) -> None: + + def max_heapify(heap_size, index): + + left, right = 2 * index + 1, 2 * index + 2 + largest = index + + if left < heap_size and array[left] > array[largest]: + largest = left + elif if right < heap_size and array[right] > array[largest]: + largest = right + elif largest != index: + array[index], array[largest] = array[largest], array[index] + max_heapify(heap_size, largest) + + for i in range(len(lst) // 2 - 1, -1, -1): + max_heapify(len(array), i) + + for i in range(len(array) - 1, 0, -1): + array[i], array[0] = array[0], array[i] + max_heapify(i, 0) + + return array +``` + +
+ +---- + +### compare two tops + + +
+ +```python +def compare_two_tops(array) -> int: + + for i in range(len(array)): + array[i] *= -1 + + heapq.heapify(array) + + while len(array) > 1: + + val1 = heapq.heappop(array) + val2 = heapq.heappop(array) + + if val1 != val2: + heapq.heappush(array, val1 - val2) + + if array: + return -heapq.heappop(array) + + return 0 +``` + +
+ +---- + +### find non-overlapping intervals + +
+ +* given an array of `intervals[i] = [start_i, end_i]`, return the minimum the non-overlapping intervals: + +
+ +```python +def non_overlapping_invervals(intervals): + + if not intervals: + return 0 + + result = [] + intervals.sort(key=lambda x: x[0]) + heapq.heappush(result, intervals[0][-1]) + + for interval in intervals[1:]: + + if result[0] <= interval[0]: + heapq.heappop(result) + + heapq.heappush(result, interval[1]) + + return len(result) +``` + +
+ +---- + +### top k frequent values + +
+ +```python +def top_k_frequent_values(list, k): + + if k == len(nums): + return nums + + # hashmap element: frequency + counter = Counter(nums) + return heapq.nlargest(k, counter.keys(), key=counter.get) +``` + +
+ +---- + +### kth largest element in a stream + +
+ +```python +class KthLargest: + + def __init__(self, k, nums): + + self.k = k + self.heap = nums + heapq.heapify(self.heap) + + while len(self.heap) > k: + heapq.heappop(self.heap) + + def add(self, val: int) -> int: + + heapq.heappush(self.heap, val) + if len(self.heap) > self.k: + heapq.heappop(self.heap) + + return self.heap[0] +``` + +
+ +---- + +### kth smallest element in a matrix + +
+ +* given an `n x n` matrix where each of the rows and columns is sorted in ascending order, return the `kth` smallest element in the matrix. + +
+ +```python +def kth_smallest(matrix, k) -> int: + + min_heap = [] + + for row in range(min(k, len(matrix))): + min_heap.append((matrix[row][0], row, 0)) + + heapq.heapify(min_heap) + + while k: + + element, row, col = heapq.heappop(min_heap) + if col < len(matrix) - 1: + heapq.heappush(min_heap, (matrix[row][cow + 1], row, col + 1)) + k -= 1 + + return element +``` + +
+ + + diff --git a/heaps/compare_two_tops.py b/heaps/compare_two_tops.py new file mode 100644 index 0000000..2aedb6a --- /dev/null +++ b/heaps/compare_two_tops.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def compare_two_tops(array) -> int: + + for i in range(len(array)): + array[i] *= -1 + + heapq.heapify(array) + + while len(array) > 1: + + val1 = heapq.heappop(array) + val2 = heapq.heappop(array) + + if val1 != val2: + heapq.heappush(array, val1 - val2) + + if array: + return -heapq.heappop(array) + + return 0 + diff --git a/heaps/heap.py b/heaps/heap.py new file mode 100644 index 0000000..4b376f4 --- /dev/null +++ b/heaps/heap.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Heap: + + def __init__(self): + + self.heap = [] + + def heapify(self, n, i): + + largest = i + left_children = 2 * i + 1 + right_children = 2 * i + 2 + + if left_children < n and self.heap[i] < self.heap[left_children]: + largest = left_children + + if right_children < n and self.heap[largest] < self.heap[right_children]: + largest = right_children + + if largest != i: + self.heap[i], self.heap[largest] = self.heap[largest], self.heap[i] + self.heapify(n, largest) + + + def insert(self, num): + + size = len(self.heap) + + if size == 0: + self.heap.append(num) + + else: + self.heap.append(num) + for i in range((size // 2) - 1, -1, -1): + self.heapify(size, i) + + + def delete_node(self, num): + + size = len(self.heap) + + i = 0 + for i in range(size): + if num == self.heap[i]: + break + + self.heap[i], self.heap[size - 1] = self.heap[size - 1], self.heap[i] + + self.heap.remove(size - 1) + + for i in range((len(self.heap) // 2) - 1, -1, -1): + self.heapify(len(self.heap), i) + + + +if __name__ == '__main__': + + h = Heap() + for n in [10, 4, 9, 8, 1, 2]: + h.insert(n) + + print (f'Max-heap array: {h.heap}') + + n = 2 + h.delete_node(n) + print(f'After deleting {n}: {h.heap}') diff --git a/heaps/heap_sort.py b/heaps/heap_sort.py new file mode 100644 index 0000000..5e4bd58 --- /dev/null +++ b/heaps/heap_sort.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def heap_sort(self, array) -> list: + + def max_heapify(heap_size, index): + + left, right = 2 * index + 1, 2 * index + 2 + largest = index + + if left < heap_size and array[left] > array[largest]: + largest = left + elif if right < heap_size and array[right] > array[largest]: + largest = right + elif largest != index: + array[index], array[largest] = array[largest], array[index] + max_heapify(heap_size, largest) + + for i in range(len(lst) // 2 - 1, -1, -1): + max_heapify(len(array), i) + + for i in range(len(array) - 1, 0, -1): + array[i], array[0] = array[0], array[i] + max_heapify(i, 0) + + return array diff --git a/heaps/heapify.py b/heaps/heapify.py new file mode 100644 index 0000000..b9cafde --- /dev/null +++ b/heaps/heapify.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +import heapq + +min_heap = [3,1,2] +heapq.heapify(min_heap) + +max_heap = [-x for x in min_heap] +heapq.heapify(max_heap) + +heapq.heappush(min_heap, 5) +heapq.heappush(min_heap, -5) + +min_elem = min_heap[0] +max_elem = -1 * max_heap[0 + +heapq.heappop(min_heap) +heapq.heappop(max_heap) + +size_min_heap = len(min_heap) +size_max_heap = len(max_heap) diff --git a/heaps/k_smallest_matrix.py b/heaps/k_smallest_matrix.py new file mode 100644 index 0000000..79789cf --- /dev/null +++ b/heaps/k_smallest_matrix.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + + +def kth_smallest(matrix, k) -> int: + + min_heap = [] + + for row in range(min(k, len(matrix))): + min_heap.append((matrix[row][0], row, 0)) + + heapq.heapify(min_heap) + + while k: + + element, row, col = heapq.heappop(min_heap) + if col < len(matrix) - 1: + heapq.heappush(min_heap, (matrix[row][cow + 1], row, col + 1)) + k -= 1 + + return element diff --git a/heaps/kth_largest_stream.py b/heaps/kth_largest_stream.py new file mode 100644 index 0000000..8a007fd --- /dev/null +++ b/heaps/kth_largest_stream.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class KthLargest: + + def __init__(self, k, nums): + + self.k = k + self.heap = nums + heapq.heapify(self.heap) + + while len(self.heap) > k: + heapq.heappop(self.heap) + + def add(self, val: int) -> int: + + heapq.heappush(self.heap, val) + if len(self.heap) > self.k: + heapq.heappop(self.heap) + + return self.heap[0] + diff --git a/heaps/max_heap.py b/heaps/max_heap.py new file mode 100644 index 0000000..5d831d2 --- /dev/null +++ b/heaps/max_heap.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class MaxHeap: + def __init__(self, heapsize): + + self.heapsize = heapsize + self.maxheap = [0] * (heapsize + 1) + self.realsize = 0 + + def add(self, element): + + self.realsize += 1 + if self.realsize > self.heapsize: + print("Too many elements!") + self.realsize -= 1 + return False + + self.maxheap[self.realsize] = element + index = self.realsize + parent = index // 2 + + while self.maxheap[index] > self.maxheap[parent] and index > 1: + self.maxheap[parent], self.maxheap[index] = self.maxheap[index], self.maxheap[parent] + index = parent + parent = index // 2 + + def peek(self): + + return self.maxheap[1] + + def pop(self): + + if self.realsize < 1: + print("Heap is empty.") + return False + else: + remove_element = self.maxheap[1] + self.maxheap[1] = self.maxheap[self.realsize] + self.realsize -= 1 + index = 1 + + while (index <= self.realsize // 2): + + left_children = index * 2 + right_children = (index * 2) + 1 + + if (self.maxheap[index] < self.maxheap[left_children] or self.maxheap[index] < self.maxheap[right_children]): + if self.maxheap[left_children] > self.maxheap[right_children]: + self.maxheap[left_children], self.maxheap[index] = self.maxheap[index], self.maxheap[left_children] + index = left_children + else: + self.maxheap[right_children], self.maxheap[index] = self.maxheap[index], self.maxheap[right_children] + index = right_children + else: + break + return remove_element + + def size(self): + return self.realsize + + def __str__(self): + return str(self.maxheap[1 : self.realsize + 1]) + + +if __name__ == "__main__": + + h = MaxHeap(5) + h.add(1) + h.add(2) + h.add(3) + print(h) + + print(h.peek()) + print(h.pop()) + print(h.pop()) + print(h.pop()) + h.add(4) + h.add(5) + print(h) + diff --git a/heaps/min_heap.py b/heaps/min_heap.py new file mode 100644 index 0000000..f0c8b00 --- /dev/null +++ b/heaps/min_heap.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class MinHeap: + + def __init__(self, size): + + self.heapsize = size + self.minheap = [0] * (size + 1) + self.realsize = 0 + + def add(self, element): + + if self.realsize + 1 > self.heapsize: + print("Too many elements!") + return False + + self.realsize += 1 + self.minheap[self.realsize] = element + + index = self.realsize + parent = index // 2 + + while self.minheap[index] < self.minheap[parent] and index > 1: + + self.minheap[parent], self.minheap[index] = self.minheap[index], self.minheap[parent] + index = parent + parent = index // 2 + + def peek(self): + + return self.minheap[1] + + def pop(self): + + if self.realsize < 1: + print("Heap is empty.") + return False + + else: + remove_element = self.minheap[1] + self.minheap[1] = self.minheap[self.realsize] + self.realsize -= 1 + index = 1 + + while index <= self.realsize // 2: + + left_children = index * 2 + right_children = (index * 2) + 1 + + if self.minheap[index] > self.minheap[left_children] or \ + self.minheap[index] > self.minheap[right_children]: + + if self.minheap[left_children] < self.minheap[right_children]: + + self.minheap[left_children], self.minheap[index] = self.minheap[index], self.minheap[left_children] + index = left_children + + else: + + self.minheap[right_children], self.minheap[index] = self.minheap[index], self.minheap[right_children] + index = right_children + else: + break + + return remove_element + + def size(self): + return self.realsize + + def __str__(self): + return str(self.minheap[1 : self.realsize + 1]) + + +if __name__ == "__main__": + # Test cases + h = MinHeap(5) + h.add(3) + h.add(1) + h.add(2) + + print(h) + print(h.peek()) + print(h.pop()) + print(h.pop()) + print(h.pop()) + h.add(4) + h.add(5) + print(h) diff --git a/heaps/non_overlapping_invervals.py b/heaps/non_overlapping_invervals.py new file mode 100644 index 0000000..0f5f04e --- /dev/null +++ b/heaps/non_overlapping_invervals.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def non_overlapping_invervals(intervals): + + if not intervals: + return 0 + + result = [] + intervals.sort(key=lambda x: x[0]) + heapq.heappush(result, intervals[0][-1]) + + for interval in intervals[1:]: + + if result[0] <= interval[0]: + heapq.heappop(result) + + heapq.heappush(result, interval[1]) + + return len(result) diff --git a/heaps/top_k_frequent.py b/heaps/top_k_frequent.py new file mode 100644 index 0000000..3918f50 --- /dev/null +++ b/heaps/top_k_frequent.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def top_k_frequent_values(list, k): + + if k == len(nums): + return nums + + # hashmap element: frequency + counter = Counter(nums) + return heapq.nlargest(k, counter.keys(), key=counter.get) diff --git a/linked_lists/README.md b/linked_lists/README.md new file mode 100644 index 0000000..baa9bee --- /dev/null +++ b/linked_lists/README.md @@ -0,0 +1,267 @@ +## linked list + +
+ +* like arrays, a linked list is used to represent sequential data. it's a linear collection of data elements (nodes) whose order is not given by their physical placement in memory (as opposed to arrays where data is stored in sequential blocks of memory). instead, each element contains an address of the next element. + +
+ +```python +class Node: + + def __init__(self, val, next=None): + self.val = val + self.next = next +``` + +
+ +* unlike an array, a linked list does not provide constant time access to an index (as it needs to interact through all `k` elements), however addition and removal of elements are constant time (`O(1)`). + * if you need to add or delete a node frequently, a linked list could be a good choice. + * if you need to access an element by index often, an array might be a better choice than a linked list. + +* linked lists can be of the following types: + * **singled linked list**: a linked list where each node points to the next node and the last node points to `None`. + * **doubly linked list**: a linked list where each node has two pointers, `next` and `prev`. the `prev` pointer of the first node and the `next` pointer of the last node point to `None`. + * **circular linked list**: a singly linked list where the past node points back to the first node. if it's doubly, the `prev` pointer of the first node points to the last node, and the `next` pointer of the last node points to the first node. + +* each node in a singly-linked list contains a value and a reference field to link to the next node. the head node (first node) usually represents the whole list. + * nodes can be added at the beginning, head needs to be updated (`current -> head` and `head = current`). + * to remove a node you set `prev.next` equal to `node.next`. if it's a double list, you also update `node.next` with `node.next.prev` to `node.prev` (and deallocate the memory). + +* adding a sentinel/dummy node at the head and/or tail might help handle many edge cases where operations have to be performed at the head or the tail. + * the presence of dummy nodes ensures that operations will never be done on the head or the tail (removing the need of conditional checks to deal with `None` pointers). the only extra steps is that they need to be removed at the end of the operation. + * examples are LRU cache (where sentinel nodes are used as pseudo-head and pseudo-tail) and tree level order traversal (where sentinel nodes are used to mark level end). + +* two pointers can be used to solve several problems: + * getting the kth from last node: have two pointers, where one is `k` nodes ahead of the other, when the node ahead reaches the end, the other node is `k` behind. + * detecting cycles: have two pointers, where one pointer increments twice as much as the other. if the two pointers meet, there is a cycle. if there is no cycle, the faster pointer takes `N/2` to reach the end of the list (`N` being the length). + * getting in the middle node: have two pointers, where one pointer increments twice as much as the other. when the faster node reaches the end of the list, the slower node will be at the middle. + + +
+ +

+ +

+ + +
+ + +---- + +### detecting cycles + +
+ +```python +def has_cycle(head) -> bool: + + if not head: + return False + + p1 = head + p2 = head.next + + while p1 != p2: + + if not p1 or not p2 or not p2.next: + return False + + p1 = p1.next + p2 = p2.next.next + + return True +``` + +
+ +---- + +### reversing the list + +
+ +* keep track of the original head node and the new head node (for instance, with two pointers). + +
+ +```python +def reverse_list(head): + + if head is None: + return head + + prev = None + curr = head + + while curr: + next_temp = curr.next // save the pointer for the next node so we can continue the loop + curr.next = prev // revert the list + prev = curr // save for the next node revert + curr = next_temp // receive the pointer for the next node so we can continue the loop + + return prev +``` + + +
+ +--- + +### removing elements + +
+ +* given a head of a linked list and a value, how to remove all the nodes of the list that have that value? + +
+ +```python +def delete_node_without_head(node): + + node.val = node.next.val + node.next = node.next.next +``` +
+ +* this problem is easy if one has to delete a node in the middle, as all you need to do is loop until the predecessor node and change the pointers. + +* however, if the node to be deleted is in the head of the list, the best way is to use a sentinel node. sentinel nodes are widely used in trees and linked lists as pseudo-heads, pseudo-tails, markers of level end, etc. they are purely functional and usually do not hold any data. their main purpose is to standardize the process (by making the list never empty or headless). + + +
+ +```python +def remove_elements(head, val): + + sentinel = ListNode(0) + sentinel.next = head + prev, node = sentinel, head + + while node: + if node.val == val: + prev.next = node.next + else: + prev = node + node = node.next + + return sentinel.next +``` + +
+ + +--- + +### remove kth node + +
+ +```python +def remove_kth_node(self, head, n): + + if head is None or head.next is None: + return None + + # find the length of the list + node, length = head, 0 + while node: + node = node.next + length += 1 + + # if n is the entire list, remove head + if n == length: + return head.next + + # loop to kth element + node, i = head, 0 + while i <= length - n: + node = node.next + i += 1 + + # remove the kth element + node.next = node.next.next + + return head +``` + +
+ +---- + +### doubly linked lists + +
+ +* in doubly linked lists, a node has a `previous` field. + +* when it comes to add and delete operations, extra attention is needed when you want to delete or insert at the beginning or at the end of the list. + + + +
+ +---- + +### swap every two nodes + +
+ +```python +def swap_pairs(head): + + if not head or not head.next: + return head + + first_node = head + second_node = head.next + + first_node.next = swap_pairs(second_node.next) + second_node.next = first_node + + return second_node +``` + +
+ +---- + + +### rotate list by k + +
+ +* the nodes in the list are already linked, so the rotation means: + * to close the linked list in the ring + * to break the ring after the new tail and in front of the new head + +* the new head will be at `n - k`, and the new tail will be at `n - k - 1` (found with `n - k % n - 1`). + +
+ +```python3 +def rotate_list_by_k(head, k): + + if head is None: + return head + + # get the size of the list + end, n = head, 1 + while end.next: + end = end.next + n += 1 + + # rotate + end.next = head + new_end, i = head, 0 + while i < n - (k % n) - 1: + new_end = new_end.next + i += 1 + + # remove cycle + new_head = new_end.next + + return new_head +``` diff --git a/linked_lists/add_two_numbers.py b/linked_lists/add_two_numbers.py new file mode 100644 index 0000000..ae53ca7 --- /dev/null +++ b/linked_lists/add_two_numbers.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + + def __init__(self, val): + self.val = val + self.next = None + + +def add_two_numbers(l1, l2): + + n1, n2, i = '', '', 1 + + while l1: + n1 += str(l1.val) + l1 = l1.next + + while l2: + n2 += str(l2.val) + l2 = l2.next + + n1 = int(n1[::-1]) + n2 = int(n2[::-1]) + n = str(n1 + n2)[::-1] + + current = Node(n[0]) + head = current + + while i < len(n): + current.next = Node(n[i]) + current = current.next + i += 1 + + return head + diff --git a/linked_lists/delete_node_without_head.py b/linked_lists/delete_node_without_head.py new file mode 100644 index 0000000..62509d0 --- /dev/null +++ b/linked_lists/delete_node_without_head.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def delete_node_without_head(node): + + node.val = node.next.val + node.next = node.next.next + diff --git a/linked_lists/detect_cycle.py b/linked_lists/detect_cycle.py new file mode 100644 index 0000000..93475eb --- /dev/null +++ b/linked_lists/detect_cycle.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + + def __init__(self, val): + self.val = val + self.next = None + + +def has_cycle(head) -> bool: + + if not head: + return False + + p1 = head + p2 = head.next + + while p1 != p2: + + if not p1 or not p2 or not p2.next: + return False + + p1 = p1.next + p2 = p2.next.next + + return True + diff --git a/linked_lists/detect_cycle_II.py b/linked_lists/detect_cycle_II.py new file mode 100644 index 0000000..6cb6de7 --- /dev/null +++ b/linked_lists/detect_cycle_II.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, x): + self.val = x + self.next = None + + +def detect_cycle(head): + + seen = set() + node = head + + while node is not None: + + if node in seen: + return node + + else: + seen.add(node) + node = node.next + + return None + diff --git a/linked_lists/doubly_linked_list.py b/linked_lists/doubly_linked_list.py new file mode 100644 index 0000000..51f4ab6 --- /dev/null +++ b/linked_lists/doubly_linked_list.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + + def __init__(self, data, previous=None): + self.data = data + self.next = None + self.previous = previous + + self.address = self + + def insert(self, data): + + while self.next: + self = self.next + node = Node(data, previous=self) + + if self.next is None: + node = Node(data, previous=self) + + self.next = node + + + +if __name__ == "__main__": + + ll = Node(0) + for n in range(1, 10): + ll.insert(n) + + while ll.next: + + this_data = ll.data + this_address = ll.address + + if ll.next is None: + this_next_data = None + this_next_address = None + else: + this_next_data = ll.next.data + this_next_address = ll.next.address + + if ll.previous is None: + this_previous_data = None + this_previous_address = None + else: + this_previous_data = ll.previous.data + this_previous_address = ll.previous.address + + + print(f'This node -> data: {this_data}, address: {this_address} | Previous node -> data: {this_previous_data}, address: {this_previous_address} | Next node -> data: {this_next_data}, address: {this_next_address}') + ll = ll.next diff --git a/linked_lists/doubly_linked_list_II.py b/linked_lists/doubly_linked_list_II.py new file mode 100644 index 0000000..827a5c0 --- /dev/null +++ b/linked_lists/doubly_linked_list_II.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + + def __init__(self, val): + self.val = val + self.next = None + self.prev = None + +class DoublyList: + + def __init__(self): + self.head = Node(0) + self.len = 0 + + def _loop(self , index): + node = self.head + p = 0 + while p < index + 1: + node = node.next + p += 1 + + return node + + def get(self, index: int) -> int: + if self.len <= index or index < 0: + return -1 + node = self._loop(index) + return node.val + + def add_at_head(self, val: int) -> None: + self.add_at_index(0, val) + + def add_at_tail(self, val: int) -> None: + self.add_at_index(self.len, val) + + def add_at_index(self, index: int, val: int) -> None: + if self.len < index: + return -1 + + if index < 0: + index = 0 + + self.len += 1 + + node = self.head + for _ in range(index): + node = node.next + + new_node = Node(val) + new_node.next = node.next + new_node.prev = node + node.next = new_node + + def delete_at_index(self, index: int) -> None: + + if self.len <= index or index < 0: + return -1 + + self.len -= 1 + + node = self.head + for _ in range(index): + node = node.next + + node.next.prev = node + node.next = node.next.next diff --git a/linked_lists/finding_intersection.py b/linked_lists/finding_intersection.py new file mode 100644 index 0000000..24e8155 --- /dev/null +++ b/linked_lists/finding_intersection.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + def __init__(self, val): + self.val = val + self.next = None + + +def get_intersection_node(self, head_a: Node, head_b: Node) -> Optional[Node]: + + seen_b = set() + + while head_b is not None: + + seen_b.add(head_b) + head_b = head_b.next + + while head_a is not None: + + if head_a in seen_b: + return head_a + + head_a = head_a.next + diff --git a/linked_lists/flatten_list.py b/linked_lists/flatten_list.py new file mode 100644 index 0000000..b4e7900 --- /dev/null +++ b/linked_lists/flatten_list.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + + +class Node: + def __init__(self, val, prev, next, child): + self.val = val + self.prev = prev + self.next = next + self.child = child + + +def dfs(prev, node): + + if not node: + return prev + + node.prev = prev + prev.next = node + temp_next = node.next + + last = dfs(node, node.child) + node.child = None + + return dfs(last, temp_next) + + +def flatten(head): + + if head is None: + return head + + sentinel = Node(None, None, head, None) + + dfs(prev=sentinel, node=head) + + # erase the pointer to sentinel and return + sentinel.next.prev = None + return sentinel.next diff --git a/linked_lists/group_odd_and_even.py b/linked_lists/group_odd_and_even.py new file mode 100644 index 0000000..30542c9 --- /dev/null +++ b/linked_lists/group_odd_and_even.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + + def __init__(self, val): + self.val = val + self.next = None + + +def group_odd_and_even(head): + + if not head: + return None + + odd = head + even = odd.next + even_head = even + + while even is not None and even.next is not None: + + odd.next = even.next + odd = odd.next + even.next = odd.next + even = even.next + + odd.next = even_head + + return head + diff --git a/linked_lists/linked_list_II.py b/linked_lists/linked_list_II.py new file mode 100644 index 0000000..2ea6c25 --- /dev/null +++ b/linked_lists/linked_list_II.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + + def __init__(self, val): + + self.val = val + self.next = None + +class LinkedList: + + def __init__(self): + + self.head = Node(0) + self.len = 0 + + def _loop(self , index): + + node = self.head + p = 0 + while p < index + 1: + node = node.next + p += 1 + + return node + + def get(self, index: int) -> int: + if self.len <= index or index < 0: + return -1 + + node = self._loop(index) + + return node.val + + def add_at_head(self, val: int) -> None: + + self.add_at_index(0, val) + + + def add_at_tail(self, val: int) -> None: + + self.add_at_index(self.len, val) + + + def add_at_index(self, index: int, val: int) -> None: + + if self.len < index: + return -1 + + if index < 0: + index = 0 + + self.len += 1 + + node = self.head + for _ in range(index): + node = node.next + + new_node = Node(val) + new_node.next = node.next + node.next = new_node + + def delete_at_index(self, index: int) -> None: + + if self.len <= index or index < 0: + return -1 + + self.len -= 1 + + node = self.head + for _ in range(index): + node = node.next + + node.next = node.next.next diff --git a/linked_lists/linked_list_fifo.py b/linked_lists/linked_list_fifo.py new file mode 100644 index 0000000..4a2b1ec --- /dev/null +++ b/linked_lists/linked_list_fifo.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + + def __init__(self, value=None): + self.value = value + self.left = None + self.right = None + + def __repr__(self): + """Prints the node""" + return f'{self.value}' + + +class LinkedListFIFO: + + def __init__(self): + self.head = None + self.tail = None + self.length = 0 + + def add_first(self, value): + self.length = 1 + node = Node(value) + self.head = node + self.tail = node + + def delete_first(self): + self.length = 0 + self.head = None + self.tail = None + + def add(self, value): + self.length += 1 + node = Node(value) + if self.tail: + self.tail.right = node + self.tail = node + + def _delete(self, node): + if not self.head or not self.head.pointer: + self.delete_first() + else: + node, prev, i = self._find(index) + if i == index and node: + self.length -= 1 + if i == 0 or not prev: + self.head = node.pointer + else: + prev.pointer = node.pointer + if not self.tail == node: + self.tail = prev + + def find(self, index): + prev = None + node = self.head + i = 0 + while node and i < index: + prev = node + node = node.right + i += 1 + return node, prev, i + + +if __name__ == '__main__': + + print('Linked List FIFO') + ll = LinkedListFIFO() + print(f'Add 1: {ll.add(1)}') + print(f'Add 2: {ll.add(2)}') + print(f'Add 3: {ll.add(3)}') + + print(f'Length: {ll.length}') + print(f'Find 1: {ll.find(1)}') + + print(f'Delete 1: {ll._delete(1)}') + print(f'Length: {ll.length}') + print(f'Find 1: {ll.find(1)}') diff --git a/linked_lists/merge_two_lists.py b/linked_lists/merge_two_lists.py new file mode 100644 index 0000000..261286d --- /dev/null +++ b/linked_lists/merge_two_lists.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, val=0, next=None): + self.val = val + self.next = next + + +def merge_two_list(list1: Optional[Node], list2: Optional[Node]) -> Optional[Node]: + + if not list1: + return list2 + + if not list2: + return list1 + + if list1.val < list2.val: + list1.next = merge_two_list(list1.next, list2) + return list1 + else: + list2.next = merge_two_list(list1, list2.next) + return list2 + diff --git a/linked_lists/remove_elements.py b/linked_lists/remove_elements.py new file mode 100644 index 0000000..81e25f1 --- /dev/null +++ b/linked_lists/remove_elements.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def remove_elements(head, val): + + sentinel = Node(0) + sentinel.next = head + prev, current = sentinel, head + + while current: + if current.val == val: + prev.next = current.next + else: + prev = current + current = current.next + + return sentinel.next + diff --git a/linked_lists/remove_kth_node.py b/linked_lists/remove_kth_node.py new file mode 100644 index 0000000..db7e14e --- /dev/null +++ b/linked_lists/remove_kth_node.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def remove_kth_node(self, head, n): + + if head is None or head.next is None: + return None + + # find the length of the list + node, length = head, 0 + while node: + node = node.next + length += 1 + + # if n is the entire list, remove head + if n == length: + return head.next + + # loop to kth element + node, i = head, 0 + while i <= length - n: + node = node.next + i += 1 + + # remove the kth element + node.next = node.next.next + + return head diff --git a/linked_lists/reverse_linked_list.py b/linked_lists/reverse_linked_list.py new file mode 100644 index 0000000..6e0a013 --- /dev/null +++ b/linked_lists/reverse_linked_list.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + def __init__(self, val=0, next): + self.val = val + self.next = next + + +def reverse_list(head: Optional[Node]) -> Optional[Node]: + + if not head or not head.next: + return head + + new_head = reverse_list(head.next) + head.next.next = head + head.next = None + + return new_head diff --git a/linked_lists/reverse_linked_list_II.py b/linked_lists/reverse_linked_list_II.py new file mode 100644 index 0000000..281a031 --- /dev/null +++ b/linked_lists/reverse_linked_list_II.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, val=0, next): + self.val = val + self.next = next + + +def reverse_list(head: Optional[Node]) -> Optional[Node]: + + if head is None: + return head + + prev = None + curr = head + + while curr: + next_temp = curr.next + curr.next = prev + prev = curr + curr = next_temp + + return prev + diff --git a/linked_lists/rotate_list_by_k.py b/linked_lists/rotate_list_by_k.py new file mode 100644 index 0000000..14ede5a --- /dev/null +++ b/linked_lists/rotate_list_by_k.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def rotate_list_by_k(head, k): + + if head is None: + return head + + # get the size of the list + end, n = head, 1 + while end.next: + end = end.next + n += 1 + + # rotate + end.next = head + new_end, i = head, 0 + while i < n - (k % n) - 1: + new_end = new_end.next + i += 1 + + # remove cycle + new_head = new_end.next + + return new_head diff --git a/linked_lists/swap_every_two_nodes.py b/linked_lists/swap_every_two_nodes.py new file mode 100644 index 0000000..3e1de31 --- /dev/null +++ b/linked_lists/swap_every_two_nodes.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, val=0, next=None): + self.val = val + self.next = next + + +def swap_pairs(head: Optional[Node]) -> Optional[Node]: + + if not head or not head.next: + return head + + first_node = head + second_node = head.next + + first_node.next = swap_pairs(second_node.next) + second_node.next = first_node + + return second_node diff --git a/math/README.md b/math/README.md new file mode 100644 index 0000000..afe3de4 --- /dev/null +++ b/math/README.md @@ -0,0 +1,174 @@ +## math + +
+ +* when dealing with floating point numbers, take note of rounding mistakes. consider using epsilon comparisons instead of equality checks (`abs(x - y) <= 1e-6` instead of `x == y`). + +
+ +--- + +### fibonnaci + +
+ +* check the dynamic programming chapter to learn how to solve this with memoization. + +
+ +```python +def fibonacci(n): + + if n == 0 or n == 1: + return n + return fibonacci(n - 1) + fibonacci(n - 2) +``` + +
+ +--- + +### determine whether a sudoku board is valid + +
+ + +
+ +```python + +''' +Input: board = +[["5","3",".",".","7",".",".",".","."] +,["6",".",".","1","9","5",".",".","."] +,[".","9","8",".",".",".",".","6","."] +,["8",".",".",".","6",".",".",".","3"] +,["4",".",".","8",".","3",".",".","1"] +,["7",".",".",".","2",".",".",".","6"] +,[".","6",".",".",".",".","2","8","."] +,[".",".",".","4","1","9",".",".","5"] +,[".",".",".",".","8",".",".","7","9"]] +Output: true +''' + +def is_valid_sudoku(board) -> bool: + + N = 9 + + rows = [set() for _ in range(N)] + cols = [set() for _ in range(N)] + boxes = [set() for _ in range(N)] + + for r in range(N): + for c in range(N): + val = board[r][c] + if val == '.': + continue + + if val in rows[r]: + return False + rows[r].add(val) + + if val in cols[c]: + return False + cols[c].add(val) + + index = (r // 3) * 3 + c // 3 + if val in boxes[index]: + return False + boxes[index].add(val) + + return True + +``` + +
+ +--- + +### check if happy number + +
+ +```python +def get_next(n): + + total_sum = 0 + while n > 0: + n, digit = divmod(n, 10) + total_sum += digit**2 + + return total_sum + + +def is_happy(self, n: int) -> bool: + + seen = set() + while n != 1 and n not in seen: + seen.add(n) + n = get_next(n) + + return n == 1 +``` + + +
+ +--- + +### get a row in a pascal triangle + +
+ +```python +def get_row(self, row: int) -> list[int]: + + if row == 0: + return [1] + + result = self.get_row(row - 1) + + return [1] + [sum(_) for _ in zip(result, result[1:])] + [1] +``` + +
+ +--- + +### work with primes + +
+ +```python +import math +import random + + +def find_greatest_common_divider(a, b) -> int: + + while(b != 0): + result = b + a, b = b, a % b + + return result + + +def _is_prime(number) -> bool: + + if number < 2: + return False + + for i in range(2, int(math.sqrt(number))): + if number % i == 0: + return False + + return True + + +def find_prime_factors(number) -> list: + + divisors = [d for d in range(2, number//2 + 1) if number % d == 0] + primes = [d for d in divisors if _is_prime(d)] + + return primes +``` diff --git a/math/binary_exponentiation.py b/math/binary_exponentiation.py new file mode 100644 index 0000000..74e293a --- /dev/null +++ b/math/binary_exponentiation.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +''' +Binary exponentiation, also known as exponentiation by squaring, is a technique for +efficiently computing the power of a number. By repeatedly squaring x and halving n, +we can quickly compute x^n using a logarithmic number of multiplications. +''' + +def binary_exp(x: float, n: int) -> float: + + if n == 0: + return 1 + + if n < 0: + return 1.0 / binary_exp(x, -1 * n) + + if n % 2 == 1: + return x * binary_exp(x * x, (n - 1) // 2) + + return binary_exp(x * x, n // 2) diff --git a/math/check_sudoku_board.py b/math/check_sudoku_board.py new file mode 100644 index 0000000..9b195d4 --- /dev/null +++ b/math/check_sudoku_board.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +''' +Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: + +- Each row must contain the digits 1-9 without repetition. +- Each column must contain the digits 1-9 without repetition. +- Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition. + +Input: board = +[["5","3",".",".","7",".",".",".","."] +,["6",".",".","1","9","5",".",".","."] +,[".","9","8",".",".",".",".","6","."] +,["8",".",".",".","6",".",".",".","3"] +,["4",".",".","8",".","3",".",".","1"] +,["7",".",".",".","2",".",".",".","6"] +,[".","6",".",".",".",".","2","8","."] +,[".",".",".","4","1","9",".",".","5"] +,[".",".",".",".","8",".",".","7","9"]] +Output: true +''' + +def is_valid_sudoku(board) -> bool: + + N = 9 + + rows = [set() for _ in range(N)] + cols = [set() for _ in range(N)] + boxes = [set() for _ in range(N)] + + for r in range(N): + for c in range(N): + val = board[r][c] + if val == '.': + continue + + if val in rows[r]: + return False + rows[r].add(val) + + if val in cols[c]: + return False + cols[c].add(val) + + index = (r // 3) * 3 + c // 3 + if val in boxes[index]: + return False + boxes[index].add(val) + + return True + diff --git a/math/fibonacci.py b/math/fibonacci.py new file mode 100644 index 0000000..6554fd0 --- /dev/null +++ b/math/fibonacci.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def fibonacci(n): + + if n == 0 or n == 1: + return n + return fibonacci(n - 1) + fibonacci(n - 2) diff --git a/math/happy_number.py b/math/happy_number.py new file mode 100644 index 0000000..235d1e6 --- /dev/null +++ b/math/happy_number.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def get_next(n): + + total_sum = 0 + while n > 0: + n, digit = divmod(n, 10) + total_sum += digit**2 + + return total_sum + + +def is_happy(self, n: int) -> bool: + + seen = set() + while n != 1 and n not in seen: + seen.add(n) + n = get_next(n) + + return n == 1 + diff --git a/math/pascal_triangle.py b/math/pascal_triangle.py new file mode 100644 index 0000000..d1c5424 --- /dev/null +++ b/math/pascal_triangle.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def get_row(self, row: int) -> list[int]: + + if row == 0: + return [1] + + result = self.get_row(row - 1) + + return [1] + [sum(_) for _ in zip(result, result[1:])] + [1] diff --git a/math/playing_with_math.py b/math/playing_with_math.py new file mode 100644 index 0000000..45d6a24 --- /dev/null +++ b/math/playing_with_math.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +import math +import random + + +def find_greatest_common_divider(a, b) -> int: + + while(b != 0): + result = b + a, b = b, a % b + + return result + + +def _is_prime(number) -> bool: + + if number < 2: + return False + + for i in range(2, int(math.sqrt(number))): + if number % i == 0: + return False + + return True + + +def find_prime_factors(number) -> list: + + divisors = [d for d in range(2, number//2 + 1) if number % d == 0] + primes = [d for d in divisors if _is_prime(d)] + + return primes diff --git a/queues/README.md b/queues/README.md new file mode 100644 index 0000000..2ae858b --- /dev/null +++ b/queues/README.md @@ -0,0 +1,376 @@ +## queues + +
+ +* queues are **first in, first out (FIFO) abstract structures** (*i.e.*, items are removed in the same order they are added) that can be implemented with two arrays or a dynamic array (linked list), as long as items are added and removed from opposite sides. + +* queues support **enqueue** (add to one end) and **dequeue** (remove from the other end, or tail). + +* if implemented with a dynamic array, a more efficient solution is to use a circular queue (ring buffer), *i.e.*, a fixed-size array and two pointers to indicate the starting and ending positions. + * an advantage of circular queues is that we can use the spaces in front of the queue. + * in a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. but using the circular queue, we can use the space to store new values. + +* queues are often used in **breath-first search** (where you store a list of nodes to be processed) or when implementing a cache. + +* in python, queues can be called with `collections.deque()` (and methods `popleft()` and `insert()`). + + + +
+ +--- + +### designing a circular queue + +
+ +* a circular queue can be built with either arrays or linked lists (nodes). + +
+ +#### with an array + +
+ +* to build a ring with a fixed size array, any of the elements could be considered as the head. + + +
+ + +```python +class CircularQueue: + + def __init__(self, size): + self.head = 0 + self.tail = 0 + self.size = size + self.queue = [None] * self.size + + def enqueue(self, value: int) -> bool: + if self.is_full(): + return False + + if self.is_empty(): + self.head = 0 + + while self.queue[self.tail] is not None: + self.tail += 1 + if self.tail == self.size: + self.tail = 0 + self.queue[self.tail] = value + + return True + + def dequeue(self) -> bool: + if self.is_empty(): + return False + + value = self.queue[self.head] + self.queue[self.head] = None + self.head += 1 + + if self.head == self.size: + self.head = 0 + + return True + + def front(self) -> int: + return self.queue[self.head] or False + + def rear(self) -> int: + return self.queue[self.tail] or False + + def is_empty(self) -> bool: + for n in self.queue: + if n is not None: + return False + return True + + def is_full(self) -> bool: + for n in self.queue: + if n is None: + return False + return True +``` + +
+ +* to enqueue, you loop the queue with the tail index until you find a `None` (even if it has to loop back): + +
+ +```python +while queue[self.tail]: + + self.tail += 1 + if self.tail == self.size: + self.tail = 0 +self.queue[self.tail] = value +``` + +
+ +* to dequeue, you simply pop the head value: + +
+ +```python +value = self.queue[self.head] +self.queue[self.head] = None +self.head += 1 +``` + +
+ +* as long as we know the length of the queue, we can instantly locate its tails based on this formula: + +
+ +``` +tail_index = (head_index + current_length - 1) % size +``` + +
+ +* there is one occasion when `tail` index is set to zero: + * when the enqueue operation adds to the last position in the array and tail has to loop back (`self.tail == self.size`). + +* there are two occasions when `head` index is set to zero: + * when the queue is checked as empty + * when the dequeue operation popped the last element in the array and head has to loop back (`self.head == self.size`). + + + +
+ +* another version used only one index (for `head`) and calculate the tail with the equation: + +
+ +```python +(self.head + self.count - 1) % self.size +```` + +
+ +* and the next tail with: + +
+ +```python +(self.head + self.count) % self.size +``` + +
+ +* and the next `head` is always given by: + +
+ +```python +(self.head + 1) % self.size +``` + +
+ +* * in the example below we also implement the methods `is_empty` and `is_full` using an extra counter variable `self.count` that can be compared to `self.size` or `0` and used to validate `rear` and `front`. + +
+ +```python +class CircularQueue: + + def __init__(self, size): + self.head = 0 + self.count = 0 + self.queue = [0] * size + self.size = size + + def _get_tail(self): + return (self.head + self.count - 1) % self.size + + def _get_next_tail(self): + return (self.head + self.count) % self.size + + def _get_next_head(self): + return (self.head + 1) % self.size + + def enqueue(self, value: int) -> bool: + + if self.is_empty(): + return False + + self.queue[self._get_next_tail()] = value + self.count += 1 + + return True + + def dequeue(self) -> bool: + + if self.is_empty(): + return False + + self.head = self._get_next_head() + self.count -= 1 + + return True + + def Front(self) -> int: + if self.is_empty(): + return False + + return self.queue[self.head] + + def Rear(self) -> int: + if self.is_empty(): + return False + + return self.queue[self._get_tail()] + + def isEmpty(self) -> bool: + return self.count == 0 + + def isFull(self) -> bool: + return self.count == self.size +``` + +
+ + + +#### with linked lists + +
+ + +* a linked list could be more memory efficient, since it does not pre-allocate memory for unused capacity (and size of the queue is not "artificial" like before). + +* note that this queue is not thread-safe: the data structure could be corrupted in a multi-threaded environment (as race-condition could occur). to mitigate this problem, one could add the protection of a lock. + +
+ +```python +class Node: + def __init__(self, value, next=None): + + self.value = value + self.next = next + + +class Queue: + + def __init__(self, size): + + self.size = size + self.count = 0 + self.head = None + self.tail = None + + def enqueue(self, value: int) -> bool: + + if self.is_full(): + return False + + if self.is_empty(): + self.head = self.tail = Node(value) + + else: + self.tail.next = Node(value) + self.tail = self.tail.next + + self.count += 1 + + return True + + def dequeue(self) -> bool: + + if self.is_empty(): + return False + + self.head = self.head.next + self.count -= 1 + + return True + + def front(self) -> int: + if self.is_empty(): + return False + return self.head.value + + def rear(self) -> int: + if self.is_empty(): + return False + return self.tail.value + + def is_empty(self) -> bool: + return self.count == 0 + + def is_full(self) -> bool: + return self.count == self.size +``` + +
+ +--- + +### a stream with rate limiter + +
+ +```python +class Logger: + + def __init__(self): + self.msg_set = set() + self.msg_queue = deque() + + def print_message(self, timestamp, message) -> bool: + + while self.msg_queue: + msg, msg_timestamp = self.msg_queue[0] + if timestamp - msg_timestamp >= 10: + self.msg_queue.popleft() + self.msg_set.remove(msg) + else: + break + + if message not in self.msg_set: + self.msg_set.add(message) + self.msg_queue.append((message, timestamp)) + return True + + return False +``` + +
+ +--- + +### moving average + +
+ +* given a stream of integers and a window size, the moving average in the sliding window can be calculated with a queue: + +
+ +```python + +class MovingAverage: + + def __init__(self, size: int): + + self.queue = [] + self.size = size + + + def next(self, val: int) -> float: + + self.queue.append(val) + + if len(self.queue) > self.size: + self.queue.pop(0) + + return sum(self.queue) / len(self.queue) +``` diff --git a/queues/circular_queue_array.py b/queues/circular_queue_array.py new file mode 100644 index 0000000..e56fddd --- /dev/null +++ b/queues/circular_queue_array.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class CircularQueue: + + def __init__(self, size): + self.head = 0 + self.tail = 0 + self.size = size + self.queue = [None] * self.size + + def enqueue(self, value: int) -> bool: + + if self.is_full(): + return False + + if self.is_empty(): + self.head = 0 + + while self.queue[self.tail] is not None: + self.tail += 1 + if self.tail == self.size: + self.tail = 0 + + self.queue[self.tail] = value + + return True + + def dequeue(self) -> bool: + + if self.is_empty(): + return False + + value = self.queue[self.head] + self.queue[self.head] = None + self.head += 1 + + if self.head == self.size: + self.head = 0 + + return True + + def front(self) -> int: + return self.queue[self.head] or False + + def rear(self) -> int: + return self.queue[self.tail] or False + + def is_empty(self) -> bool: + for n in self.queue: + if n is not None: + return False + return True + + def is_full(self) -> bool: + for n in self.queue: + if n is None: + return False + return True + diff --git a/queues/moving_average.py b/queues/moving_average.py new file mode 100644 index 0000000..292ae7a --- /dev/null +++ b/queues/moving_average.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +''' +Given a stream of integers and a window size, calculate the moving average in the sliding window. +''' + +class MovingAverage: + + def __init__(self, size: int): + + self.queue = [] + self.size = size + + + def next(self, val: int) -> float: + + self.queue.append(val) + + if len(self.queue) > self.size: + self.queue.pop(0) + + return sum(self.queue) / len(self.queue) + diff --git a/queues/queue_list.py b/queues/queue_list.py new file mode 100644 index 0000000..f650535 --- /dev/null +++ b/queues/queue_list.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, value, next=None): + + self.value = value + self.next = next + + +class Queue: + + def __init__(self, size): + + self.size = size + self.count = 0 + self.head = None + self.tail = None + + def enqueue(self, value: int) -> bool: + + if self.is_full(): + return False + + if self.is_empty(): + self.head = self.tail = Node(value) + + else: + self.tail.next = Node(value) + self.tail = self.tail.next + + self.count += 1 + + return True + + def dequeue(self) -> bool: + + if self.is_empty(): + return False + + self.head = self.head.next + self.count -= 1 + + return True + + def front(self) -> int: + if self.is_empty(): + return False + return self.head.value + + def rear(self) -> int: + if self.is_empty(): + return False + return self.tail.value + + def is_empty(self) -> bool: + return self.count == 0 + + def is_full(self) -> bool: + return self.count == self.size + diff --git a/queues/queue_list_II.py b/queues/queue_list_II.py new file mode 100644 index 0000000..cdaecaa --- /dev/null +++ b/queues/queue_list_II.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class CircularQueue: + + def __init__(self, size): + self.head = 0 + self.count = 0 + self.queue = [0] * size + self.size = size + + def _get_tail(self): + return (self.head + self.count - 1) % self.size + + def _get_next_tail(self): + return (self.head + self.count) % self.size + + def _get_next_head(self): + return (self.head + 1) % self.size + + def enqueue(self, value: int) -> bool: + + if self.is_empty(): + return False + + self.queue[self._get_next_tail()] = value + self.count += 1 + + return True + + def dequeue(self) -> bool: + + if self.is_empty(): + return False + + self.head = self._get_next_head() + self.count -= 1 + + return True + + def Front(self) -> int: + if self.is_empty(): + return False + + return self.queue[self.head] + + def Rear(self) -> int: + if self.is_empty(): + return False + + return self.queue[self._get_tail()] + + def isEmpty(self) -> bool: + return self.count == 0 + + def isFull(self) -> bool: + return self.count == self.size diff --git a/queues/stream_with_rate_limiter.py b/queues/stream_with_rate_limiter.py new file mode 100644 index 0000000..da58743 --- /dev/null +++ b/queues/stream_with_rate_limiter.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Logger: + + def __init__(self): + self.msg_set = set() + self.msg_queue = deque() + + def print_message(self, timestamp, message) -> bool: + + while self.msg_queue: + msg, msg_timestamp = self.msg_queue[0] + if timestamp - msg_timestamp >= 10: + self.msg_queue.popleft() + self.msg_set.remove(msg) + else: + break + + if message not in self.msg_set: + self.msg_set.add(message) + self.msg_queue.append((message, timestamp)) + return True + + return False + diff --git a/searching/README.md b/searching/README.md new file mode 100644 index 0000000..bdeaccd --- /dev/null +++ b/searching/README.md @@ -0,0 +1,288 @@ +## binary search + +
+ +* a binary search operates on a (sorted) contiguous sequence with a specified left and right index (this is called the **search space**). + +* binary searching is composed of 3 sections: + * **pre-processing**: sort if collection is unsorted + * **binary search**: using a loop or recursion to divide search space in half after each comparison (`O(log(N)`) + * **post-processing**: determine viable candidates in the remaining space + +* there are 3 "templates" when writing a binary search: + * `while left < right`, with `left = mid + 1` and `right = mid - 1` + * `while left < right`, with `left = mid + 1` and `right = mid`, and `left` is returned + * `while left + 1 < right`, with `left = mid` and `right = mid`, and `left` and `right` are returned + +* in python, `bisect.bisect_left()` returns the index at which the `val` should be inserted in the sorted array. + +
+ +```python +from bisect import bisect_left + +def binary_search(array, val, low=0, high=None): + + high = high or len(array) + position = bisect_left(array, val, low, high) + + if position != high and array[position] == value: + return position + + return -1 +``` + +---- + +### iterative + +
+ +```python + if lens(nums) == 0: + return False + + lower, higher = 0, len(array) + + while lower < higher: + mid = (higher + lower) // 2 + + if array[mid] == item: + return mid + elif array[mid] > item: + higher = mid - 1 + else: + lower = mid + 1 + + return False +``` + +
+ +---- + +### recursive + +
+ +```python +def binary_search_recursive(array, item, higher=None, lower=0): + + higher = higher or len(array) + + if higher < lower: + return False + + mid = (higher + lower) // 2 + + if item == array[mid]: + return mid + + elif item < array[mid]: + return binary_search_recursive(array, item, mid - 1, lower) + + else: + return binary_search_recursive(array, item, higher, mid + 1) +``` + +
+ +* or a slightly different version that does not carry `lower` and `higher`: + +
+ +```python +def binary_search_recursive(array, item): + + start, end = 0, len(array) + mid = (end - start) // 2 + + while len(array) > 0: + if array[mid] == item: + return True + elif array[mid] > item: + return binary_search_recursive(array[mid + 1:], item) + else: + return binary_search_recursive(array[:mid], item) + + return False +``` + +
+ +--- + +### in a matrix + +
+ +```python +def binary_search_matrix(matrix, item, lower=0, higher=None): + + if not matrix: + return False + + rows = len(matrix) + cols = len(matrix[0]) + higher = higher or rows * cols + + if higher > lower: + mid = (higher + lower) // 2 + row = mid // cols + col = mid % cols + + if item == matrix[row][col]: + return row, col + elif item < matrix[row][col]: + return binary_search_matrix(matrix, item, lower, mid - 1) + else: + return binary_search_matrix(matrix, item, mid + 1, higher) + + return False +``` + +
+ +--- + +### find the square root + +
+ +```python + +def sqrt(x) -> int: + + if x < 2: + return x + + left, right = 2, x // 2 + + while left <= right: + + mid = (right + left) // 2 + num = mid * mid + + if num > x: + right = mid - 1 + elif num < x: + left = mid + 1 + else: + return mid + + return right +``` + +
+ +--- + +### find min in a rotated array + +
+ +```python +def find_min(nums): + + left, right = 0, len(nums) - 1 + + while nums[left] > nums[right]: + + mid = (left + right) // 2 + + if nums[mid] < nums[right]: + right = mid + else: + left = mid + 1 + + return nums[left] +``` + +
+ +--- + +### find a peak element + +
+ +* a peak element is an element that is strictly greater than its neighbors. + +
+ +```python +def peak_element(nums): + + left, right = 0, len(nums) - 1 + + while left < right: + + mid = (left + right) // 2 + + if nums[mid + 1] < nums[mid]: + right = mid + else: + left = mid + 1 + + return left +``` + +
+ +--- + +### find a desired sum + +
+ +* if the array is sorted: + +
+ +```python +def find_pairs_max_sum(array, desired_sum): + + i, j = 0, len(array) - 1 + + while i < j: + this_sum = array[i] + array[j] + if this_sum == desired_sum: + return array[i], array[j] + elif this_sum > desired_sum: + j -= 1 + else: + i += 1 + + return False +``` + +
+ +* if the array is not sorted, use a hash table: + +
+ +```python +def find_pairs_not_sorted(array, desired_sum): + + lookup = {} + + for item in array: + key = desired_sum - item + + if key in lookup.keys(): + lookup[key] += 1 + else: + lookup[key] = 1 + + for item in array: + key = desired_sum - item + + if item in lookup.keys(): + if lookup[item] == 1: + return (item, key) + else: + lookup[item] -= 1 + + return False +``` diff --git a/searching/binary_search.py b/searching/binary_search.py new file mode 100644 index 0000000..fb8052f --- /dev/null +++ b/searching/binary_search.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def binary_search_recursive(array, item, higher=None, lower=0): + + higher = higher or len(array) + + if higher < lower: + return False + + mid = (higher + lower) // 2 + + if item == array[mid]: + return mid + + elif item < array[mid]: + return binary_search_recursive(array, item, mid - 1, lower) + + else: + return binary_search_recursive(array, item, higher, mid + 1) + + +def binary_search_iterative(array, item): + + if lens(nums) == 0: + return False + + lower, higher = 0, len(array) + + while lower < higher: + mid = (higher + lower) // 2 + + if array[mid] == item: + return mid + + elif array[mid] > item: + higher = mid - 1 + + else: + lower = mid + 1 + + return False + + +def binary_search_matrix(matrix, item, lower=0, higher=None): + + if not matrix: + return False + + rows = len(matrix) + cols = len(matrix[0]) + higher = higher or rows * cols + + if higher > lower: + mid = (higher + lower) // 2 + row = mid // cols + col = mid % cols + + if item == matrix[row][col]: + return row, col + elif item < matrix[row][col]: + return binary_search_matrix(matrix, item, lower, mid - 1) + else: + return binary_search_matrix(matrix, item, mid + 1, higher) + + return False diff --git a/searching/find_minimum_rotated_array.py b/searching/find_minimum_rotated_array.py new file mode 100644 index 0000000..b72d547 --- /dev/null +++ b/searching/find_minimum_rotated_array.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def find_min(nums): + + left, right = 0, len(nums) - 1 + + while nums[left] > nums[right]: + + mid = (left + right) // 2 + + if nums[mid] < nums[right]: + # note above that it's on right + right = mid + else: + left = mid + 1 + + return nums[left] + diff --git a/searching/find_pair_nums.py b/searching/find_pair_nums.py new file mode 100644 index 0000000..d860497 --- /dev/null +++ b/searching/find_pair_nums.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def bs(array, item): + + start, end = 0, len(array) + mid = (end - start) // 2 + + while len(array) > 0: + if array[mid] == item: + return True + elif array[mid] > item: + return bs(array[mid + 1:], item) + else: + return bs(array[:mid], item) + + return False + + +def find_pairs_bs(array, desired_sum): + + for i in range(len(array)): + num1 = array[i] + desired_num = desired_sum - num1 + if bs(array[i + 1:], desired_num) == True: + return (num1, desired_num) + + return False + + +def find_pairs_max_sum(array, desired_sum): + + i, j = 0, len(array) - 1 + + while i < j: + this_sum = array[i] + array[j] + if this_sum == desired_sum: + return array[i], array[j] + elif this_sum > desired_sum: + j -= 1 + else: + i += 1 + + return False + + +def find_pairs_not_sorted(array, desired_sum): + + lookup = {} + + for item in array: + key = desired_sum - item + + if key in lookup.keys(): + lookup[key] += 1 + else: + lookup[key] = 1 + + for item in array: + key = desired_sum - item + + if item in lookup.keys(): + if lookup[item] == 1: + return (item, key) + else: + lookup[item] -= 1 + + return False + + + +if __name__ == "__main__": + + desired_sum = 8 + array1 = [1, 2, 3, 9] + array2 = [1, 2, 4, 5, 4] + array3 = [2, 1, 6, 3, 11, 2] + + assert(find_pairs_bs(array1, desired_sum) == False) + assert(find_pairs_bs(array2, desired_sum) == (4, 4)) + assert(find_pairs_max_sum(array1, desired_sum) == False) + assert(find_pairs_max_sum(array2, desired_sum) == (4,4)) + assert(find_pairs_not_sorted(array1, desired_sum) == False) + assert(find_pairs_not_sorted(array2, desired_sum) == (4, 4)) + assert(find_pairs_not_sorted(array3, desired_sum) == (2, 6)) diff --git a/searching/find_peak_element.py b/searching/find_peak_element.py new file mode 100644 index 0000000..7a47dca --- /dev/null +++ b/searching/find_peak_element.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +# A peak element is an element that is strictly greater than its neighbors. + +def peak_element(nums): + + left, right = 0, len(nums) - 1 + + while left < right: + + mid = (left + right) // 2 + + if nums[mid + 1] < nums[mid]: + right = mid + else: + left = mid + 1 + + return left + diff --git a/searching/sqrt_x.py b/searching/sqrt_x.py new file mode 100644 index 0000000..3fda6a3 --- /dev/null +++ b/searching/sqrt_x.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def sqrt(x) -> int: + + if x < 2: + return x + + left, right = 2, x // 2 + + while left <= right: + + mid = (right + left) // 2 + num = mid * mid + + if num > x: + right = mid - 1 + + elif num < x: + left = mid + 1 + + else: + return mid + + return right diff --git a/sets/README.md b/sets/README.md new file mode 100644 index 0000000..2af7932 --- /dev/null +++ b/sets/README.md @@ -0,0 +1,61 @@ +## sets + +
+ + +### implementing an `O(1)` randomized set class + +
+ +* a set structure where we would implement `insert`, `delete`, and `get_random` at `O(1)` time. + +* this type of structure is widely used in statistical algorithms such as markov chain monte carlo and metropolis-hastings algorithms, which needs sampling from a probability distribution when it's difficult to compute the distribution itself. + +* candidates for `O(1)` average insert time are: + * **hashmaps (or hashsets)**: to be able to implement `get_random` at `O(1)` (choose a random index and retrieve a random element), we would have to convert hashmap keys in a list, which is `O(N)`. a solution is to build a list of keys aside and use this list to compute `get_random` in `O(1)`. + * **array lists**: we would have `O(N)` with `delete`. the solution would be delete the last value (first swap the element to delete with the last one, then pop the last element out). for that, we need to compute an index of each element in `O(N)`, and we need a hashmap that stores `element -> index`. + +* either way, we need the same combination of data structures: a hashmap and an array. + * an array keeps the values appended in order. `delete` always replace elements to the end. + * an dictionary maps the values (key) to the corresponding length of the array (their index) so it guarantees `O(1)` lookup and provides a list for `random.choice()`. + +
+ +```python +import random + +class RandomizedSet: + + def __init__(self): + self.random_set = {} + self.index_list = [] + + def insert(self, val: int) -> bool: + + if val in self.random_set.keys(): + return False + + self.index_list.append(val) + self.random_set[val] = len(self.index_list) + + return True + + def remove(self, val: int) -> bool: + + if val in self.random_set.keys(): + + last_element = self.index_list[-1] + index_val = self.random_set[val] + self.index_list[index_val] = last_element + self.random_set[last_element] = index_val + + self.index_list.pop() + del self.random_set[val] + + return True + + return False + + def get_random(self) -> int: + return random.choice(self.index_list) + ``` diff --git a/sets/random_set.py b/sets/random_set.py new file mode 100644 index 0000000..b74b978 --- /dev/null +++ b/sets/random_set.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +import random + + +class RandomizedSet: + + def __init__(self): + + self.random_set = {} + self.index_list = [] + + def insert(self, val: int) -> bool: + + if val in self.random_set.keys(): + return False + + self.index_list.append(val) + self.random_set[val] = len(self.index_list) + + return True + + def remove(self, val: int) -> bool: + + if val in self.random_set.keys(): + + last_element = self.index_list[-1] + index_val = self.random_set[val] + self.index_list[index_val] = last_element + self.random_set[last_element] = index_val + + self.index_list.pop() + del self.random_set[val] + + return True + + return False + + def get_random(self) -> int: + + return random.choice(self.index_list) + diff --git a/sorting/README.md b/sorting/README.md new file mode 100644 index 0000000..3da1f9a --- /dev/null +++ b/sorting/README.md @@ -0,0 +1,55 @@ +## sorting + +
+ +* **inversions** in a sequence are pair of elements that are out of order with respect to the ordering relation. a sorting algorithm is a sequence of operations that reduces inversions to zero. + +* a **topological sort** of a directed graph is a way of ordering the list of nodes such that if `(a, b)` is an edge of the graph, then `a` appears before `b`. this type of sorting does not work if a graph has cycles or is not directed. + +* because of their efficiencies, you usually want to use either merge sort or quick sort (`O(N log (N)`). + +* other type of sorting algorithms can be seen below and in this directory's source code: + +
+ + +

+ +

+ +
+ +--- + +### merge sort + +
+ +```python +def ms(array): + + if len(array) < 2: + return array + + mid = len(array) // 2 + left = array[:mid] + right = array[mid:] + + result, i, j = [], 0, 0 + + while i < len(left) and j < len(right): + + if left[i] <= right[j]: + result.append(left[i]) + i += 1 + else: + result.append(right[j]) + j += 1 + + if left[i:]: + result.extend(left[i:]) + if right[j:]: + result.extend(right[j:]) + + return result +``` diff --git a/sorting/bubble_sort.py b/sorting/bubble_sort.py new file mode 100644 index 0000000..c4dd7bf --- /dev/null +++ b/sorting/bubble_sort.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def bubble_sort(array) + + has_swapped = True + + while has_swapped: + has_swapped = False + + for i in range(len(array) - 1): + if array[i] > array[i + 1]: + array[i], array[i + 1] = array[i + 1], array[i] + has_swapped = True diff --git a/sorting/bucket_sort.py b/sorting/bucket_sort.py new file mode 100644 index 0000000..693c0d3 --- /dev/null +++ b/sorting/bucket_sort.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def bucket_sort(array, k): + + buckets = [[] for _ in range(k)] + + shift = min(array) + max_val = max(array) - shift + bucket_size = max(1, max_val / k) + + for i, e in enumerate(array): + + index = (e - shift) // bucket_size + + if index == k: + buckets[k - 1].append(e) + else: + buckets[index].append(e) + + for bucket in buckets: + bucket.sort() + + sorted_array = [] + for bucket in buckets: + sorted_array.extend(bucket) + + for i in range(len(array)): + array[i] = sorted_array[i] diff --git a/sorting/counting_sort.py b/sorting/counting_sort.py new file mode 100644 index 0000000..b4979d8 --- /dev/null +++ b/sorting/counting_sort.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def counting_sort(array): + + k = max(array) + counts = [0] * (k + 1) + + for e in array: + counts[e] += 1 + + starting_index = 0 + for i, count in enumerate(counts): + counts[i] = starting_index + starting_index += count + + sorted_list = [0] * len(array) + + for e in array: + + sorted_list[counts[e]] = e + counts[e] += 1 + + for i in range(len(array)): + array[i] = sorted_list[i] diff --git a/sorting/insertion_sort.py b/sorting/insertion_sort.py new file mode 100644 index 0000000..b60c520 --- /dev/null +++ b/sorting/insertion_sort.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def insertion_sort(array): + + for i in range(1, len(array)): + current_index = i + + while current_index > 0 and array[current_index - 1] > array[current_index]: + + array[current_index], array[current_index - 1] = array[current_index - 1], array[current_index] + current_index -= 1 diff --git a/sorting/merge_sort.py b/sorting/merge_sort.py new file mode 100644 index 0000000..9f8b227 --- /dev/null +++ b/sorting/merge_sort.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def merge_sort(array): + + # part 1: recursively divide the array into subarrays + if len(array) < 2: + return array + + mid = len(array) // 2 + left = merge_sort(array[:mid]) + right = merge_sort(array[mid:]) + + # part 2: merge the subarrays + result = [] + i, j = 0, 0 + + while i < len(left) and j < len(right): + if left[i] <= right[j]: + result.append(left[i]) + i +=1 + else: + result.append(right[j]) + j +=1 + + if left[i:]: + result.extend(left[i:]) + if right[j:]: + result.extend(right[j:]) + + return result + diff --git a/sorting/quick_sort.py b/sorting/quick_sort.py new file mode 100644 index 0000000..144cbd9 --- /dev/null +++ b/sorting/quick_sort.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def quick_sort_partition(array): + + pivot, array = array[0], array[1:] + + lower = [i for i in array if i <= pivot] + higher = [i for i in array if i > pivot] + + return lower, pivot, higher + + +def quick_sort_divided(array): + + if len(array) < 2: + return array + + lower, pivot, higher = quick_sort_partition(array) + + return quick_sort_divided(lower) + [pivot] + quick_sort_divided(higher) + diff --git a/sorting/seletction_sort.py b/sorting/seletction_sort.py new file mode 100644 index 0000000..4e71206 --- /dev/null +++ b/sorting/seletction_sort.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def selection_sort(array): + + for i in range(len(array)): + min_index = i + + for j in range(i + 1, len(array)): + if array[j] < array[min_index]: + min_index = j + + array[min_index], array[i] = array[i], array[min_index] diff --git a/src/abstract_structures/hash_tables/hash_table.py b/src/abstract_structures/hash_tables/hash_table.py deleted file mode 100644 index 61c41a4..0000000 --- a/src/abstract_structures/hash_tables/hash_table.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - -''' design a Hash table using chaining to avoid collisions.''' - - -#import abstract_structures.linked_list.linked_list_fifo -#import abstract_structures.linked_list.node - -from linked_list_fifo import LinkedListFIFO - - - -class HashTableLL(object): - def __init__(self, size): - self.size = size - self.slots = [] - self._createHashTable() - - def _createHashTable(self): - for i in range(self.size) : - self.slots.append(LinkedListFIFO()) - - def _find(self, item): - return item%self.size - - def _add(self, item): - index = self._find(item) - self.slots[index].addNode(item) - - def _delete(self, item): - index = self._find(item) - self.slots[index].deleteNode(item) - - def _print(self): - for i in range(self.size): - print('\nSlot {}:'.format(i)) - print(self.slots[i]._printList()) - - - - -def test_hash_tables(): - H1 = HashTableLL(3) - for i in range (0, 20): - H1._add(i) - H1._print() - print('\n\nNow deleting:') - H1._delete(0) - H1._delete(1) - H1._delete(2) - H1._delete(0) - - H1._print() - - - -if __name__ == '__main__': - test_hash_tables() diff --git a/src/abstract_structures/linked_list/check_pal.py b/src/abstract_structures/linked_list/check_pal.py deleted file mode 100644 index 4e8eb76..0000000 --- a/src/abstract_structures/linked_list/check_pal.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - -''' Given a linked list, check if the nodes form a palindrome ''' - -from linked_list_fifo import LinkedListFIFO, Node -from node import Node - -def isPal(l): - - if len(l1) < 2: - return True - if l1[0] != l1[-1]: - return False - - return isPal(l1[1:-1]) - - - -def checkllPal(ll): - node = ll.head - l = [] - - while node: - l.append(node.value) - node = node.pointer - - return isPal(l) - - - - - -if __name__ == '__main__': - - ll = LinkedListFIFO() - l1 = [1, 2, 3, 2, 1] - - for i in l1: - ll.addNode(i) - - assert(checkllPal(ll) == True) - - ll.addNode(2) - ll.addNode(3) - - assert(checkllPal(ll) == False) diff --git a/src/abstract_structures/queues/queue.py b/src/abstract_structures/queues/queue.py deleted file mode 100644 index 68995fb..0000000 --- a/src/abstract_structures/queues/queue.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - -''' an (inefficient) class for a queue ''' - -class Queue(object): - def __init__(self): - self.items = [] - - def isEmpty(self): - return not bool(self.items) - - def enqueue(self, item): - self.items.insert(0, item) - - def dequeue(self): - return self.items.pop() - - def size(self): - return len(self.items) - - def peek(self): - return self.items[-1] - - def __repr__(self): - return '{}'.format(self.items) - - - -if __name__ == '__main__': - queue = Queue() - print("Is the queue empty? ", queue.isEmpty()) - print("Adding 0 to 10 in the queue...") - for i in range(10): - queue.enqueue(i) - print("Queue size: ", queue.size()) - print("Queue peek : ", queue.peek()) - print("Dequeue...", queue.dequeue()) - print("Queue peek: ", queue.peek()) - print("Is the queue empty? ", queue.isEmpty()) - print(queue) \ No newline at end of file diff --git a/src/abstract_structures/stacks/banlance_parenthesis_str_stack.py b/src/abstract_structures/stacks/banlance_parenthesis_str_stack.py deleted file mode 100644 index 7892be1..0000000 --- a/src/abstract_structures/stacks/banlance_parenthesis_str_stack.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - -''' use a stack to balance the parenteses of a string ''' - - -from stack import Stack - -def balance_par_str_with_stack(str1): - - s = Stack() - balanced = True - index = 0 - - while index < len(str1) and balanced: - - symbol = str1[index] - - if symbol == "(": - s.push(symbol) - - else: - if s.isEmpty(): - balanced = False - else: - s.pop() - - index = index + 1 - - if balanced and s.isEmpty(): - return True - - else: - return False - - - -if __name__ == '__main__': - print(balance_par_str_with_stack('((()))')) - print(balance_par_str_with_stack('(()')) diff --git a/src/abstract_structures/stacks/stack.py b/src/abstract_structures/stacks/stack.py deleted file mode 100644 index 87134a7..0000000 --- a/src/abstract_structures/stacks/stack.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -''' define the stack class ''' - - -class Stack(object): - def __init__(self): - self.items = [] - - def isEmpty(self): - return not bool(self.items) - - def push(self, value): - self.items.append(value) - - def pop(self): - value = self.items.pop() - if value: - return value - else: - print("Stack is empty.") - - def size(self): - return len(self.items) - - def peek(self): - if self.items: - return self.items[-1] - else: - print('Stack is empty.') - - def __repr__(self): - return '{}'.format(self.items) - - - - -if __name__ == '__main__': - stack = Stack() - print("Is the stack empty? ", stack.isEmpty()) - print("Adding 0 to 10 in the stack...") - for i in range(10): - stack.push(i) - print("Stack size: ", stack.size()) - print("Stack peek : ", stack.peek()) - print("Pop...", stack.pop()) - print("Stack peek: ", stack.peek()) - print("Is the stack empty? ", stack.isEmpty()) - print(stack) \ No newline at end of file diff --git a/src/neat_builtin_examples/dicts/delete_duplicate_char_str.py b/src/neat_builtin_examples/dicts/delete_duplicate_char_str.py deleted file mode 100644 index b186f2b..0000000 --- a/src/neat_builtin_examples/dicts/delete_duplicate_char_str.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -import string - -def delete_unique_word(str1): - ''' find and delete all the duplicate characters in a string ''' - - # create ordered dict - table_c = { key : 0 for key in string.ascii_lowercase} - - # fill the table with the chars in the string - for i in str1: - table_c[i] += 1 - - # scan the table to find times chars > 1 - for key, value in table_c.items(): - if value > 1: - str1 = str1.replace(key, "") - - return str1 - - -def test_delete_unique_word(): - str1 = "google" - assert(delete_unique_word(str1) == 'le') - print('Tests passed!') - -if __name__ == '__main__': - test_delete_unique_word() - diff --git a/src/neat_builtin_examples/dicts/find_anagram_hash_function.py b/src/neat_builtin_examples/dicts/find_anagram_hash_function.py deleted file mode 100644 index fb2a61b..0000000 --- a/src/neat_builtin_examples/dicts/find_anagram_hash_function.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def hash_func(astring, tablesize): - sum = 0 - for pos in range(len(astring)): - sum = sum + ord(astring[pos]) - return sum%tablesize - - -def find_anagram_hash_function(word1, word2): - ''' verify if words are anagrams by comparying hash functions''' - tablesize = 11 - return hash_func(word1, tablesize) == hash_func(word2, tablesize) - - - - -def test_find_anagram_hash_function(module_name='this module'): - word1 = 'buffy' - word2 = 'bffyu' - word3 = 'bffya' - assert(find_anagram_hash_function(word1, word2) == True) - assert(find_anagram_hash_function(word1, word3) == False) - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - - -if __name__ == '__main__': - test_find_anagram_hash_function() - diff --git a/src/neat_builtin_examples/dicts/find_dice_probabilities.py b/src/neat_builtin_examples/dicts/find_dice_probabilities.py deleted file mode 100644 index 10e2d48..0000000 --- a/src/neat_builtin_examples/dicts/find_dice_probabilities.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -from collections import Counter, defaultdict - -def find_dice_probabilities(S, n_faces=6): - ''' given 2 dice, determine number of ways to sum S if all dice are rolled ''' - - if S > 2*n_faces or S < 2: return None - - cdict = Counter() - ddict = defaultdict(list) - - for dice1 in range(1, n_faces+1): - for dice2 in range(1, n_faces+1): - t = [dice1, dice2] - cdict[dice1+dice2] += 1 - ddict[dice1+dice2].append( t) - - return [cdict[S], ddict[S]] - - -def test_find_dice_probabilities(module_name='this module'): - n_faces = 6 - S = 5 - results = find_dice_probabilities(S, n_faces) - print(results) - assert(results[0] == len(results[1])) - - -if __name__ == '__main__': - test_find_dice_probabilities() diff --git a/src/neat_builtin_examples/dicts/veirfy_two_strings_are_anagrams.py b/src/neat_builtin_examples/dicts/veirfy_two_strings_are_anagrams.py deleted file mode 100644 index c10266c..0000000 --- a/src/neat_builtin_examples/dicts/veirfy_two_strings_are_anagrams.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -import string - - -def verify_two_strings_are_anagrams(str1, str2): - """ find whether two words are anagrams. Since sets do not count occurency, and sorting is O(nlogn) - we will use hash tables. We scan the first string and add all the character occurences. Then we - scan the second tring and decrease all the caracther occurences. If all the counts are zero, it is - an anagram""" - - # create the hash table - ana_table = {key:0 for key in string.ascii_lowercase} - - # scan first string - for i in str1: - ana_table[i] += 1 - - # scan second string - for i in str2: - ana_table[i] -= 1 - - # verify whether all the entries are 0 - if len(set(ana_table.values())) < 2: return True - else: return False - - -def test_verify_two_strings_are_anagrams(): - str1 = 'marina' - str2 = 'aniram' - assert(verify_two_strings_are_anagrams(str1, str2) == True) - str1 = 'google' - str2 = 'gouglo' - assert(verify_two_strings_are_anagrams(str1, str2) == False) - print('Tests passed!') - - -if __name__ == '__main__': - test_verify_two_strings_are_anagrams() - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/comb_str.py b/src/neat_builtin_examples/lists_and_strings/comb_str.py deleted file mode 100644 index 9e9f966..0000000 --- a/src/neat_builtin_examples/lists_and_strings/comb_str.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' give all the combinations of a str or list: - >>> l1 = (1, 2, 3) - >>> comb_str(l1) - [[1], [1, [2]], [1, [2, 3]], [1, [3]], [2], [2, 3], [3]] - >>> comb_str([]) - [] -''' - - - -def comb_str(l1): - if len(l1) < 2: return l1 - result = [] - for i in range(len(l1)): - result.append([l1[i]]) - for comb in comb_str(l1[i+1:]): - result.append([l1[i], comb]) - return result - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_all_permutations_string.py b/src/neat_builtin_examples/lists_and_strings/find_all_permutations_string.py deleted file mode 100644 index 4c90e6f..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_all_permutations_string.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - - -def find_all_permutations_string(str1): - ''' print all the permutations of a given string, recursive so runtime is O(n*(n-1)) ''' - res = [] - if len(str1) == 1: - res = [str1] - else: - for i, c in enumerate(str1): - for perm in find_all_permutations_string(str1[:i] + str1[i+1:]): - res += [c + perm] - return res - - -def find_all_permutations_string_crazy(str1): - ''' crazy simple way of find all the permutations of a string, also using recursion''' - return [str1] if len(str1) == 1 else [c + perm for i, c in enumerate(str1) for perm in find_all_permutations_string_crazy(str1[:i]+str1[i+1:])] - - -def find_all_permutations_string_stdlib(str1): - ''' find all the permutations of a string just using the available packages ''' - from itertools import permutations - perms = [''.join(p) for p in permutations(str1)] - return perms - - -def test_find_all_permutations_string(): - str1 = "abc" - perm_set = {'abc', 'bac', 'cab', 'acb', 'cba', 'bca'} - assert(set(find_all_permutations_string(str1)) == perm_set) - assert(set(find_all_permutations_string_crazy(str1)) == perm_set) - assert(set(find_all_permutations_string_stdlib(str1)) == perm_set) - print('Tests passed!') - - -if __name__ == '__main__': - test_find_all_permutations_string() - - - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/find_closest_num_seq.py b/src/neat_builtin_examples/lists_and_strings/find_closest_num_seq.py deleted file mode 100644 index c3c587c..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_closest_num_seq.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - - -def find_closest_num_seq_unsorted(seq): - ''' Find the Closest two Numbers in a Sequence. If we do this without sorting - first, the runtime will be O(n^2) ''' - dd = float("inf") - for x in seq: - for y in seq: - if x == y: continue - d = abs(x - y) - if d < dd: - xx, yy, dd = x, y, d - return xx, yy - - -def find_closest_num_seq_sorted(seq): - ''' However, if we sort first, we can achieve it with runtime O(n log n): ''' - seq.sort() - print(seq) - dd = float("inf") - for i in range(len(seq) - 1): - x, y = seq[i], seq[i+1] - if x == y: continue - d = abs(x-y) - if d < dd: - xx, yy, dd = x, y, d - return xx, yy - - -def test_find_closest_num_seq(module_name='this module'): - import random - seq = [random.randrange(100) for i in range(20)] - print(seq) - print(find_closest_num_seq_sorted(seq)) - print(find_closest_num_seq_unsorted(seq)) - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - - -if __name__ == '__main__': - test_find_closest_num_seq() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_duplicate_num_array.py b/src/neat_builtin_examples/lists_and_strings/find_duplicate_num_array.py deleted file mode 100644 index d9330ba..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_duplicate_num_array.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -def find_duplicate_num_array(l1): - """ an array contains n numbers ranging from 0 to n-1. there are some numbers duplicated, but it is - not clear how many. this code find a duplicate number in the array. """ - - """ A naive solution is to sort the input array, costing O(nlogn). Another solution is the utilization of a hash set. When the number is scanned, it is either in or not. It costs O(n) auxiliary memory to accomodate a hash set. A third solution, that only costs O(1) is consider that indexes in an array with length n are in the range n-1. If there were no duplication in the n numbers from 0 to n-1, we could rearange them sorted, so that each i has its ith number. Since there are duplicates, some locations are occupied by multiple numbers, other are vacant. So every number is scanned one by one, if it the number is not in the right i, it is compared to that from i, and the duplicate can be found, or we swap. Continue until a duplicate is found.""" - - for i in range(len(l1)): - if l1[i] == i: continue - elif l1[i] < 0 or l1[i] > len(l1)-1: - return None - elif l1[i] == l1[l1[i]]: - return True - else: - aux = l1[l1[i]] - l1[l1[i]] = l1[i] - l1[i] = aux - else: - return False - -def test_find_duplicate_num_array(): - a = [1,3,5,2,4,0] - b = [1,3,5,2,1,0,4] - c = [0,0] - assert(find_duplicate_num_array(b) == True) - assert(find_duplicate_num_array(a) == False) - assert(find_duplicate_num_array(c) == True) - print('Tests passed!') - -if __name__ == '__main__': - test_find_duplicate_num_array() - - - - - - - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/find_edit_distance.py b/src/neat_builtin_examples/lists_and_strings/find_edit_distance.py deleted file mode 100644 index f709424..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_edit_distance.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def find_edit_distance(str1, str2): - ''' computes the edit distance between two strings ''' - m = len(str1) - n = len(str2) - diff = lambda c1, c2: 0 if c1 == c2 else 1 - E = [[0] * (n + 1) for i in range(m + 1)] - for i in range(m + 1): - E[i][0] = i - for j in range(1, n + 1): - E[0][j] = j - for i in range(1, m + 1): - for j in range(1, n + 1): - E[i][j] = min(E[i-1][j] + 1, E[i][j-1] + 1, E[i-1][j-1] + diff(str1[i-1], str2[j-1])) - return E[m][n] - - -def test_find_edit_distance(): - s = 'sunday' - t = 'saturday' - assert(find_edit_distance(s, t) == 3) - print('Tests passed!') - - -if __name__ == '__main__': - test_find_edit_distance() - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/find_first_non_repetead_char.py b/src/neat_builtin_examples/lists_and_strings/find_first_non_repetead_char.py deleted file mode 100644 index a6b57a0..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_first_non_repetead_char.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' find the first non-repetead char in a str. - ---> we use a dict to count occurences - >>> find_non_rep_char("cut") - 'c' - >>> s1 = 'google' - >>> find_non_rep_char(s1) - 'l' - >>> find_non_rep_char('ccc') - >>> find_non_rep_char('') -''' - -from collections import Counter -def find_non_rep_char(s1): - aux_dict = Counter() - for i in s1: - aux_dict[i] += 1 - for i in s1: - if aux_dict[i] < 2: return i # remember it's <2 - # not handling anything else: return None - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_if_is_substr.py b/src/neat_builtin_examples/lists_and_strings/find_if_is_substr.py deleted file mode 100644 index d8fd6d6..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_if_is_substr.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Find if a s2 is a substring of a s1 - >>> s1 = 'buffy is a vampire slayer' - >>> s2 = 'vampire' - >>> s3 = 'angel' - >>> isSubstr(s1, s2) - True - >>> isSubstr(s1, s3) - False - >>> s4 = 'pirevam' - >>> find_substr(s2, s4) - True - >>> find_substr(s1, s4) - False -''' - -def isSubstr(s1, s2): - if s1 in s2 or s2 in s1: return True - return False - - -def find_substr(s1, s2): - if s1 == '' or s2 == '': return True #empty str is always substr - for i, c in enumerate(s1): - if c == s2[0]: - test_s1 = s1[i:]+s1[:i] - return isSubstr(s2, test_s1) - return False - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_if_only_unique_chars.py b/src/neat_builtin_examples/lists_and_strings/find_if_only_unique_chars.py deleted file mode 100644 index fe804bb..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_if_only_unique_chars.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def unique_char(s): - if len(s) > 256: return False - set_chars = set() - for i in s: - if i in set_chars: - return False - else: - set_chars.add(i) - return True - - - -def unique_char_no_add(s): - if len(s) < 2: return True - for i, c in enumerate(s): - for j in s[i+1:]: - if j == c: - return False - return True - - -def main(): - s1 = 'abcdefg' - s2 = 'buffy' - s3 = '' - print(unique_char(s1)) - print(unique_char(s2)) - print(unique_char(s3)) - print(unique_char_no_add(s1) ) - print(unique_char_no_add(s2)) - print(unique_char_no_add(s3)) - - -if __name__ == '__main__': - main() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_long_con_inc_subseq.py b/src/neat_builtin_examples/lists_and_strings/find_long_con_inc_subseq.py deleted file mode 100644 index cb01c54..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_long_con_inc_subseq.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -def find_long_con_inc(seq): - ''' find the longest continuous increasing subsequence''' - one_seq = [] - result = [] - - for i in range(0, len(seq)-1): - pivot = seq[i] - if pivot <= seq[i+1]: - one_seq.append(pivot) - else: - one_seq.append(pivot) - if len(one_seq) > len(result): - result = one_seq - one_seq = [] - return result - - -def test_find_long_con_inc(module_name='this module'): - seq = [1, -2, 3, 5, 1, -1, 4, -1, 6] - long_con_inc = [-2,3,5] - - assert(find_long_con_inc(seq) == long_con_inc ) - -if __name__ == '__main__': - test_find_long_con_inc() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_majority_in_seq.py b/src/neat_builtin_examples/lists_and_strings/find_majority_in_seq.py deleted file mode 100644 index da38c11..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_majority_in_seq.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -def find_majority_in_seq(seq): - ''' find value which occurrence is greater than the total occurrence of all other elements ''' - times = 1 - result = seq[0] - for i in range(len(seq)): - if times == 0: - result = seq[i] - times = 1 - elif seq[i] == result: - times +=1 - else: - times -=1 - - if times == 0: return None - else: - count = 0 - for i, c in enumerate(seq): - if c == result: - count += 1 - return result, count - - -def test_find_majority_in_seq(): - seq = [1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 6] - seq2 = [1, 2, 3] - assert(find_majority_in_seq(seq) == (4, 4)) - assert(find_majority_in_seq(seq2) == None) - print('Tests passed!') - -if __name__ == '__main__': - test_find_majority_in_seq() - - - - - - - - - -""" ->>> A = [1, 2, 3, 2, 2, 4, 2, 5, 2] ->>> find_majority(A) -(2, 5) ->>> A = [1] ->>> find_majority(A) -(1, 1) ->>> A = [1, 2, 3, 2, 5, 6, 7] ->>> find_majority(A) -No Majority Element. -""" - - - diff --git a/src/neat_builtin_examples/lists_and_strings/find_max_profit.py b/src/neat_builtin_examples/lists_and_strings/find_max_profit.py deleted file mode 100644 index 9b5d583..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_max_profit.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def find_max_profit_On(seq): - ''' find the most profit from a seq with O(n) ''' - max_profit = 0 - min_value = seq[0] - for i in range(1, len(seq)): - profit_here = seq[i]- min_value - if profit_here > max_profit: - max_profit = profit_here - else: - if min_value > seq[i]: - min_value = seq[i] - - return max_profit - - -def find_max_profit_On2(seq): - ''' find the most profit from a seq with O(n2) ''' - max_profit = 0 - for i in range(len(seq)-1): - for j in range (i, len(seq)-1): - if seq[j] - seq[i] > max_profit: - max_profit = seq[j] - seq[i] - return max_profit - - -def test_find_max_profit(): - seq = [9,11,5,7,16,1] - assert(find_max_profit_On(seq) == 11) - assert(find_max_profit_On2(seq) == 11) - seq = [1,15,2,3,4,3] - assert(find_max_profit_On(seq) == 14) - assert(find_max_profit_On2(seq) == 14) - print('Tests passed!') - - -if __name__ == '__main__': - test_find_max_profit() - - diff --git a/src/neat_builtin_examples/lists_and_strings/find_max_subarray.py b/src/neat_builtin_examples/lists_and_strings/find_max_subarray.py deleted file mode 100644 index 36a9328..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_max_subarray.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -def find_max_subarray1(l1): - ''' calculate the greatest sum of subarrays from an array. - An array with n elements has n(n+1)/2 subarrays so force brute cost O(n^2). - What we can do is to check when a sum becomes a negative number or zero, and then discard, since - this will not "add" anything to the new event... When the sum decreases, it gets the previous sum. ''' - sum_new, result = 0, 0 - for c in l1: - result = max(result, sum_new) - sum_new += c - if sum_new <= 0: sum_new = 0 - return result - - - -def find_max_subarray2(l1): - ''' find the contiguous subarray which has the largest sum (Kadane's algorithm in O(n)) - with extra O(n) space ''' - sum_old = [l1[0]] - for c in l1: - sum_old.append(max(c, sum_old [-1] + c)) - return max(sum_old) - - -def test_find_max_subarray(): - l1 = [-2, 1, -3, 4, -1, 2, 1, -5, 4] - l2 = [-1, 3, -5, 4, 6, -1, 2, -7, 13, -3] - assert(find_max_subarray1(l1)) == 6) - assert(find_max_subarray1(l2)) == 17) - assert(find_max_subarray2(l1) == 6) - assert(find_max_subarray2(l2) == 17) - print('Tests passed!') - -if __name__ == '__main__': - test_find_max_subarray() - - - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/find_palindrome_rec.py b/src/neat_builtin_examples/lists_and_strings/find_palindrome_rec.py deleted file mode 100644 index ec79fa0..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_palindrome_rec.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def find_palindrome_rec(s): - ''' recursive way of checking whether a str is a palindrome ''' - if len(s) > 1: - if s[0] != s[-1]: return False - else: find_palindrome_rec(s[1:-1]) - return True - - -def test_find_palindrome_rec(module_name='this module'): - str1 = 'radar' - str2 = "" - str3 = 'x' - str4 = 'hello' - assert(find_palindrome_rec(str1) == True) - assert(find_palindrome_rec(str2) == True) - assert(find_palindrome_rec(str3) == True) - assert(find_palindrome_rec(str4) == False) - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - - -if __name__ == '__main__': - test_find_palindrome_rec() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_product_without_division.py b/src/neat_builtin_examples/lists_and_strings/find_product_without_division.py deleted file mode 100644 index 82bcf0d..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_product_without_division.py +++ /dev/null @@ -1,33 +0,0 @@ -def find_product_without_division(seq): - '''Given an array of numbers, replace each number with the product of all the numbers in the array except the number itself *without* using division ''' - forw = [] - bacw = [] - - for i in range(len(seq)): - prod_f = 1 - prod_b = 1 - for next in range(i+1, len(seq)): - prod_f *= seq[next] - for before in range(0, i): - prod_b *= seq[before] - forw.append(prod_f) - bacw.append(prod_b) - - print(bacw) - print(forw) - for i in range(len(seq)): - seq[i] = forw[i]*bacw[i] - - return seq - - - -def test_find_product_without_division(): - seq = [2,3,4] - result = [12, 8, 6] - print(find_product_without_division(seq)) - - - -if __name__ == '__main__': - test_find_product_without_division() diff --git a/src/neat_builtin_examples/lists_and_strings/find_subst_in_str.py b/src/neat_builtin_examples/lists_and_strings/find_subst_in_str.py deleted file mode 100644 index 6caff9b..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_subst_in_str.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def find_subst_in_str(str1, set1): - sub_str1 = '' - found = False - - while set1: - for c in str1: - if c in set1: - set1.remove(c) - found = True - if found == True: - sub_str1 += c - if len(set1) == 0: found = False - return sub_str1 - - - -def test_find_subst_in_str(module_name='this module'): - str1 = 'ydxahbcscdk' - - set1 = {'a','b','c','d'} - result = 'dxahbc' - - assert( find_subst_in_str(str1, set1)==result) - - set2 = {'a','b','c'} - result2 = 'ahbc' - assert( find_subst_in_str(str1, set2)==result2) - - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - - -if __name__ == '__main__': - test_find_subst_in_str() - diff --git a/src/neat_builtin_examples/lists_and_strings/find_two_missing_numbers_in_sequence.py b/src/neat_builtin_examples/lists_and_strings/find_two_missing_numbers_in_sequence.py deleted file mode 100644 index 24beab5..0000000 --- a/src/neat_builtin_examples/lists_and_strings/find_two_missing_numbers_in_sequence.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -import math - -def find_two_missing_numbers(l1): - """ Two numbers out of n numbers from 1 to n are missing. The remaining n-2 numbers are in the - array but not sorted. Find the missing numbers The sum1 is the sum of all the elements in n. The - sum2 is the sum of all the elements in n-2. sum1 - sum2 = num1 + num2 = s. The prod1 is the prod of - all the elements in n. The prod2 is the prod of all the elements in n-2. prod1/prod2 = num1*num2 = - p. Runtime is O(n), because it scan 3 times. Space is O(1) - - - In case of finding one integer, Let the missing number be M. We know that the sum of first N - natural numbers is N*(N+1)/2. Traverse through the array once and calculate the sum. This is the - sum of first N natural numbers – M or S=N*(N+1)/2 – M. Therefore M = N*(N+1)/2 – S. - """ - - n_min_2 = len(l1) - n = n_min_2 + 2 - sum1, sum2, prod1, prod2 = 0,0,1,1 - sum2 = sum(l1[:]) - sum1 = sum(range(1,n+1)) - s = sum1 - sum2 - - for i in range(1, n-1): - prod1 = prod1*i - prod2 = prod2*l1[i-1] - - prod1 = prod1*n*(n-1) - p = prod1/prod2 - num1 = (s + math.sqrt(s*s - 4*p))/2 - num2 = (s - math.sqrt(s*s - 4*p))/2 - - return num1, num2 - - - -def test_find_two_missing_numbers(): - l1 = [1, 3, 5] - result = find_two_missing_numbers(l1) - assert(result[0] == 2.0 or result[0] == 4.0) - print('Tests passed!') - - -if __name__ == '__main__': - test_find_two_missing_numbers() - - - - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/greatest_sum_sub_array.py b/src/neat_builtin_examples/lists_and_strings/greatest_sum_sub_array.py deleted file mode 100644 index 10bf2f1..0000000 --- a/src/neat_builtin_examples/lists_and_strings/greatest_sum_sub_array.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def greatest_sum_sub_array(l1): - sum_new = 0 - results = [] - for i, c in enumerate(l1): - sum_old = sum_new - sum_new = sum_old + c - if sum_new <= 0 or sum_new < sum_old: - sum_new = 0 - results.append(sum_old) - continue - results.append(sum_new) - results.sort() - return results.pop() - -def test_greatest_sum_sub_array(): - l1 = [1, -4, 20, -4, 5, 15, 3] - assert(greatest_sum_sub_array(l1) == 23) - print('Tests passed!') - -if __name__ == '__main__': - test_greatest_sum_sub_array() - diff --git a/src/neat_builtin_examples/lists_and_strings/longest_common_substring.py b/src/neat_builtin_examples/lists_and_strings/longest_common_substring.py deleted file mode 100644 index 13aa0af..0000000 --- a/src/neat_builtin_examples/lists_and_strings/longest_common_substring.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - - -def longest_common_substring(str1, str2): - ''' find the largest commom substring from 2 strings ''' - m = [[0 for i in range(len(str2) + 1)] for k in range(len(str1) + 1)] - lcs = None - max_len = 0 - for y in range(1, len(str1) + 1): - for x in range(1, len(str2) + 1): - m[y][x] = m[y - 1][x - 1] + 1 if (str1[y - 1] == str2[x - 1]) else 0 - - if m[y][x] > max_len: - max_len = m[y][x] - lcs = str1[(y - max_len):y] - return max_len, lcs - - -def test_longest_common_substring(): - str1 = 'buffy is a vampire slayer' - str2 = 'aaas bampires vslay' - assert(longest_common_substring(str1, str2) == (6, 'ampire')) - print('Tests passed!') - - -if __name__ == '__main__': - test_longest_common_substring() - - diff --git a/src/neat_builtin_examples/lists_and_strings/merge_two_sorted_arrays.py b/src/neat_builtin_examples/lists_and_strings/merge_two_sorted_arrays.py deleted file mode 100644 index 617d183..0000000 --- a/src/neat_builtin_examples/lists_and_strings/merge_two_sorted_arrays.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -def merge_two_sorted_arrays(a1, a2): - """ merge two sorted arrays, keeping the final sorted """ - if len(a1) >= len(a2): - biga = a1 - smalla = a2 - else: - biga = a2 - smalla = a1 - final = [] - count = 0 - for i in range(len(biga)): - if count < len(smalla) and smalla[count] < biga[i]: - final.append(smalla[count]) - count+=1 - final.append(biga[i]) - return final - -def test_merge_two_sorted_arrays(): - a1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - a2 = [3, 6, 7] - assert(merge_two_sorted_arrays(a1, a2) == [0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 9, 10]) - print('Tests passed!') - -if __name__ == '__main__': - test_merge_two_sorted_arrays() - - - - - - - - - diff --git a/src/neat_builtin_examples/lists_and_strings/perm_str.py b/src/neat_builtin_examples/lists_and_strings/perm_str.py deleted file mode 100644 index 6c32dfa..0000000 --- a/src/neat_builtin_examples/lists_and_strings/perm_str.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' give all the permutation of a str: - >>> str1 = 'hat' - >>> perm_str(str1) - ['hat', 'hta', 'aht', 'ath', 'tha', 'tah'] - >>> perm_str('') - '' -''' - -def perm_str(str1): - if len(str1) < 2: return str1 - result = [] - for i in range(len(str1)): - for perm in perm_str(str1[:i] + str1[i+1:]): - result.append(str1[i] + perm) - return result - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/lists_and_strings/print_all_seq_with_cont_num.py b/src/neat_builtin_examples/lists_and_strings/print_all_seq_with_cont_num.py deleted file mode 100644 index 1bfa771..0000000 --- a/src/neat_builtin_examples/lists_and_strings/print_all_seq_with_cont_num.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def print_all_seq_with_cont_num(s): - ''' print all sequences with cont. numbers (2 at least) whose sum is a given s ''' - if s < 3: return s - small = 1 - big = 2 - sum_here = big + small - result = [] - - while small < (1+s)/2: - sum_here = sum(range(small, big)) - if sum_here < s: - big += 1 - elif sum_here > s: - small +=1 - else: - result.append(list(range(small, big))) - big += 1 - - return result - -def test_print_all_seq_with_cont_num(): - s = 15 - sum_set_for_s = [[1,2,3,4,5], [4,5,6], [7,8]] - assert(print_all_seq_with_cont_num(s) == sum_set_for_s) - s = 1 - assert(print_all_seq_with_cont_num(s)== 1) - s = 0 - assert(print_all_seq_with_cont_num(s) == 0) - print('Tests passed!') - - -if __name__ == '__main__': - test_print_all_seq_with_cont_num() - diff --git a/src/neat_builtin_examples/lists_and_strings/remove_specified_char_from_str.py b/src/neat_builtin_examples/lists_and_strings/remove_specified_char_from_str.py deleted file mode 100644 index 7c7dc36..0000000 --- a/src/neat_builtin_examples/lists_and_strings/remove_specified_char_from_str.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' remove the chars in a list from a string - ---> handle whitespaces!!!! - >>> remove_char_str('I love google', 'oe') - 'I lv ggl' - >>> remove_char_str('google', '') - 'google' - >>> remove_char_str('google', 'google') - '' -''' - - -def remove_char_str(s1, charlist): - set_aux = set(charlist) - lt_aux = [] # we use list intead of concat. strs because it's more efficient - for c in s1: - if c not in set_aux: - lt_aux.append(c) - return ''.join(lt_aux) # IF NON CHARS, RETURN '' not NONE! - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/lists_and_strings/removing_duplicates_seq.py b/src/neat_builtin_examples/lists_and_strings/removing_duplicates_seq.py deleted file mode 100644 index 9399ae3..0000000 --- a/src/neat_builtin_examples/lists_and_strings/removing_duplicates_seq.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def removing_duplicates_seq(seq): - ''' if the values are hashable, we can use set and generators to remove duplicates - in a sequence ''' - seen = set() - for item in seq: - if item not in seen: - yield item - seen.add(item) - -def removing_duplicates_seq_not_hash(seq, key= None): - ''' if the item is not hashable, such as dictionaries ''' - seen = set() - for item in seq: - val = item if key is None else key[item] - if item not in seen: - yield item - seen.add(val) - - - -def test_removing_duplicates_seq(): - seq = [1, 2, 2, 2, 3, 3, 4, 4, 4] - dict = {'a':1, 'b':2, 'a':2, 'a':1} - assert(list(removing_duplicates_seq(seq)) == [1,2,3,4]) - assert(list(removing_duplicates_seq_not_hash(dict)) == ['a', 'b']) - print('Tests passed!'.center(20, '*')) - - -if __name__ == '__main__': - test_removing_duplicates_seq() - - diff --git a/src/neat_builtin_examples/lists_and_strings/reverse_str.py b/src/neat_builtin_examples/lists_and_strings/reverse_str.py deleted file mode 100644 index 5752173..0000000 --- a/src/neat_builtin_examples/lists_and_strings/reverse_str.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python - -author = "Mari Wahl" -email = "marina.w4hl@gmail.com" - - -# timeit is used for benchmarking. -from timeit import timeit - - -def reverse_1(string): - """ - Slowest function. Use a list and str.join to reverse the string. - :param string: the string to be reversed. - :return: a reversed string. - """ - reversed_string = [] - # Iterates from the last to the first character. - for i in range(len(string) - 1, -1, -1): - # Appends the character to the list. - reversed_string.append(string[i]) - return ''.join(reversed_string) - - -def reverse_2(string): - """ - Same principle as reverse_1. One-liner cousin. - :param string: the string to be reversed. - :return: a reversed string. - """ - return ''.join([character for character in [string[i] for i in range(len(string) - 1, -1, -1)]]) - - -def reverse_3(string): - """ - Another one-liner. We make a list from the characters of the string and reverse it. - :param string: the string to be reversed. - :return: a reversed string. - """ - return ''.join([character for character in string][::-1]) - -# Overkill of elegance. A bit too passionate but it defines this lambda function well. -# Simply returns the string backwards. As fast as concise. -reverse_lambda = lambda s: s[::-1] - -# We define some short strings to test our functions. -strings = ('buffy', 'foo', 'bar') -# We announce what we are doing. -print(', '.join(strings), ' should appear reversed if the function is working.\n') -print('{:<30}:'.format('Function name'), 'benchmarking result (lower is better):') -# Iterate over a tuple of functions. -for function in (reverse_1, reverse_2, reverse_3, reverse_lambda): - name = function.__name__ if function.__name__ != "" else 'reverse_lambda' - # We print the function's name and its benchmark result. - print("{:<30}:".format(name), timeit(name + "('string')", setup='from __main__ import ' + name)) - # We print the output so that we can check if the function is working as expected. - print(', '.join(map(function, strings)), '\n') -# We wait until the user wants to quit. -input('Press Return to quit.') diff --git a/src/neat_builtin_examples/lists_and_strings/reverse_string_inplace_rec.py b/src/neat_builtin_examples/lists_and_strings/reverse_string_inplace_rec.py deleted file mode 100644 index f2f164d..0000000 --- a/src/neat_builtin_examples/lists_and_strings/reverse_string_inplace_rec.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python - -author = "Mari Wahl" -email = "marina.w4hl@gmail.com" - - - -def reverse_string_inplace_rec(s): - ''' takes a string and returns its reverse''' - if s: - s = s[-1] + reverse_string_inplace_rec(s[:-1]) - return s - -def reverse_string_inplace(s): - s = s[::-1] - if s[0] == '\0': - s = s[1:] - s += '\0' - return s - - - -def test_reverse_string_inplace_rec(module_name='this module'): - s = 'hello' - s2 = 'buffy\0' - assert(reverse_string_inplace(s) == 'olleh') - assert(reverse_string_inplace(s2) == 'yffub\0') - assert(reverse_string_inplace_rec(s) == 'olleh') - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - -if __name__ == '__main__': - test_reverse_string_inplace_rec() - diff --git a/src/neat_builtin_examples/lists_and_strings/reverse_words_sentence.py b/src/neat_builtin_examples/lists_and_strings/reverse_words_sentence.py deleted file mode 100644 index 5fcee65..0000000 --- a/src/neat_builtin_examples/lists_and_strings/reverse_words_sentence.py +++ /dev/null @@ -1,117 +0,0 @@ - -#!/usr/bin/env python - -author = "Mari Wahl" -email = "marina.w4hl@gmail.com" - -""" Here we want to invert the words in a string, without reverting -the words. - -Important things to remember: - -1. python strings are immutable -2. The last word doesn't not end by a space, so we need to make -sure we get the last word too - -The solution consists of two loops, -1) revert all the characters with 2 pointers -2) search for spaces and revert the words, two pointers too -3) You can represent space as ' ' or as u'\u0020' -4) Do we want to look to ! ; , . etc? - -In the solutions bellow, we show how to do this logic, and how to use -python's methods to do in a few lines -""" - - -# EXAMPLE NUMBER 1 - -def reverser(string1, p1=0, p2=None): - if len(string1) < 2: - return string1 - p2 = p2 or len(string1)-1 - while p1 < p2: - aux = string1[p1] - string1[p1] = string1[p2] - string1[p2] = aux - p1 += 1 - p2 -= 1 - - - -def reversing_words_setence_logic(string1): - reverser(string1) - p = 0 - start = 0 - while p < len(string1): - if string1[p] == u"\u0020": - reverser(string1,start,p-1) - start = p+1 - p += 1 - reverser(string1,start,p-1) - - return "".join(string1) - - - -# EXAMPLE NUMBER 2 AND 3 USING PYTHON AWESOMESAUCE - -def reversing_words_setence_py(str1): - ''' reverse the words in a sentence''' - words = str1.split() - rev_set = " ".join(reversed(words)) - return rev_set - -def reversing_words_setence_py2(str1): - """ - Reverse the order of the words in a sentence. - :param string: the string which words wilL be reversed. - :return: the reversed string. - """ - words = str1.split(' ') - words.reverse() - return ' '.join(words) - - -# EXAMPLE 4, VERY SILLY, USING BRUTE FORCE -# -def reverse_words_brute(string): - """ - Reverse the order of the words in a sentence. - :param string: the string which words wil lbe reversed. - :return: the reversed string. - """ - word, sentence = [], [] - for character in string: - if character != ' ': - word.append(character) - else: - # So we do not keep multiple whitespaces. An empty list evaluates to False. - if word: - sentence.append(''.join(word)) - word = [] - # So we do not keep multiple whitespaces. An empty list evaluates to False. - if word != '': - sentence.append(''.join(word)) - sentence.reverse() - return ' '.join(sentence) - - - -# TESTS - -def test_reversing_words_sentence(): - str1 = "Buffy is a Vampire Slayer" - assert(reversing_words_setence_py(str1) == "Slayer Vampire a is Buffy") - assert(reversing_words_setence_py2(str1) == "Slayer Vampire a is Buffy") - assert(reverse_words_brute(str1) == "Slayer Vampire a is Buffy") - assert(reversing_words_setence_logic(list(str1)) == "Slayer Vampire a is Buffy") - - print("Tests passed!") - - - -if __name__ == '__main__': - test_reversing_words_sentence() - - diff --git a/src/neat_builtin_examples/lists_and_strings/sum_two_numbers_sequence.py b/src/neat_builtin_examples/lists_and_strings/sum_two_numbers_sequence.py deleted file mode 100644 index bee6a8d..0000000 --- a/src/neat_builtin_examples/lists_and_strings/sum_two_numbers_sequence.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def sum_two_numbers_sequence(seq, s): - """ given an increasing sorted array and an integer s, find if there is a pair of two numbers in the array whose sum is s. It takes O(n). """ - l1 = seq[:] - l2 = seq[:] - l2.reverse() - n1 = l1.pop() - n2 = l2.pop() - while l2 and l1: - sum_here = n1 + n2 - if sum_here > s: - n1 = l1.pop() - elif sum_here < s: - n2 = l2.pop() - else: - return True - return False - - - -def test_sum_two_numbers_sequence(): - l1 = [1,2,3,4,5,6,7,8] - s = 7 - assert(sum_two_numbers_sequence(l1, s) == True) - print('Tests passed!') - - -if __name__ == '__main__': - test_sum_two_numbers_sequence() - - - diff --git a/src/neat_builtin_examples/lists_and_strings/verify_if_perm.py b/src/neat_builtin_examples/lists_and_strings/verify_if_perm.py deleted file mode 100644 index b4476be..0000000 --- a/src/neat_builtin_examples/lists_and_strings/verify_if_perm.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def ver_perm(s1, s2): - ''' worst case O(nlogn + mlogm) = O(NlogN) ''' - if len(s1) != len(s2): return False - s1 = sorted(s1) - s2 = sorted(s2) - return s1 == s2 - -from collections import Counter -def ver_perm_dict(s1, s2): - ''' worst case O(n + n +2n) = O(n)''' - if len(s1) != len(s2): return False - dict_aux = Counter() - for c in s1: - dict_aux[c] += 1 - for c in s2: - dict_aux[c] -= 1 - for item in dict_aux: - if dict_aux[item]: - return False - return True - -import time -def main(): - s1 = 'ufyfbufyfb' - s2 = 'buffybuffy' - s3 = 'uuyfbuuyfb' - s4 = '' - start = time.time() - print(ver_perm(s1, s2)) - print(ver_perm(s1, s3)) - print(ver_perm(s1, s4)) - final1 = time.time() - start - - start = time.time() - print(ver_perm_dict(s1, s2)) - print(ver_perm_dict(s1, s3)) - print(ver_perm_dict(s1, s4)) - final2 = time.time() - start - - print(final2-final1) - -if __name__ == '__main__': - main() - diff --git a/src/neat_builtin_examples/numbers/convert_dec_to_any_base_rec.py b/src/neat_builtin_examples/numbers/convert_dec_to_any_base_rec.py deleted file mode 100644 index 63240b8..0000000 --- a/src/neat_builtin_examples/numbers/convert_dec_to_any_base_rec.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def convert_dec_to_any_base_rec(number, base): - ''' convert an integer to a string in any base''' - convertString = '012345679ABCDEF' - if number < base: return convertString[number] - else: - return convert_dec_to_any_base_rec(number//base, base) + convertString[number%base] - - - - -def test_convert_dec_to_any_base_rec(module_name='this module'): - number = 9 - base = 2 - assert(convert_dec_to_any_base_rec(number, base) == '1001') - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - - -if __name__ == '__main__': - test_convert_dec_to_any_base_rec() - diff --git a/src/neat_builtin_examples/numbers/convert_from_decimal.py b/src/neat_builtin_examples/numbers/convert_from_decimal.py deleted file mode 100644 index 6c2c8ed..0000000 --- a/src/neat_builtin_examples/numbers/convert_from_decimal.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -def convert_from_decimal(number, base): - ''' convert any decimal number to another base. ''' - multiplier, result = 1, 0 - while number > 0: - result += number%base*multiplier - multiplier *= 10 - number = number//base - return result - - -def test_convert_from_decimal(): - number, base = 9, 2 - assert(convert_from_decimal(number, base) == 1001) - print('Tests passed!') - - -if __name__ == '__main__': - test_convert_from_decimal() - - diff --git a/src/neat_builtin_examples/numbers/convert_from_decimal_larger_bases.py b/src/neat_builtin_examples/numbers/convert_from_decimal_larger_bases.py deleted file mode 100644 index f8a7d71..0000000 --- a/src/neat_builtin_examples/numbers/convert_from_decimal_larger_bases.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def convert_from_decimal_larger_bases(number, base): - ''' convert any decimal number to a number in a base up to 20''' - strings = "0123456789ABCDEFGHIJ" - result = "" - while number > 0: - digit = number%base - result = strings[digit] + result - number = number//base - return result - -def test_convert_from_decimal_larger_bases(): - number, base = 31, 16 - assert(convert_from_decimal_larger_bases(number, base) == '1F') - print('Tests passed!') - -if __name__ == '__main__': - test_convert_from_decimal_larger_bases() - - diff --git a/src/neat_builtin_examples/numbers/convert_to_decimal.py b/src/neat_builtin_examples/numbers/convert_to_decimal.py deleted file mode 100644 index 6c7af35..0000000 --- a/src/neat_builtin_examples/numbers/convert_to_decimal.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def convert_to_decimal(number, base): - ''' convert any number in another base to the decimal base''' - multiplier, result = 1, 0 - while number > 0: - result += number%10*multiplier - multiplier *= base - number = number//10 - return result - - -def test_convert_to_decimal(): - number, base = 1001, 2 - assert(convert_to_decimal(number, base) == 9) - print('Tests passed!') - - -if __name__ == '__main__': - test_convert_to_decimal() - - diff --git a/src/neat_builtin_examples/numbers/find_fibonacci_seq.py b/src/neat_builtin_examples/numbers/find_fibonacci_seq.py deleted file mode 100644 index 911714d..0000000 --- a/src/neat_builtin_examples/numbers/find_fibonacci_seq.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -import math - -def find_fibonacci_seq_rec(n): - ''' implements the nth fibonacci value in a recursive exponential runtime ''' - if n < 2: return n - return find_fibonacci_seq_rec(n - 1) + find_fibonacci_seq_rec(n - 2) - - - -def find_fibonacci_seq_iter(n): - ''' return the nth fibonacci value in a iterative O(n^2) runtime ''' - if n < 2: return n - a, b = 0, 1 - for i in range(n): - a, b = b, a + b - return a - - -def find_fibonacci_seq_form(n): - ''' return the nth fibonacci value implemented by the formula, nearly constant-time algorithm, - but, it has a poor precise (after 72 it starts to become wrong) ''' - sq5 = math.sqrt(5) - phi = (1 + sq5) / 2 - return int(math.floor(phi ** n / sq5)) - - - -def test_find_fib(): - n = 10 - assert(find_fibonacci_seq_rec(n) == 55) - assert(find_fibonacci_seq_iter(n) == 55) - assert(find_fibonacci_seq_form(n) == 55) - print('Tests passed!') - - - -if __name__ == '__main__': - test_find_fib() - - diff --git a/src/neat_builtin_examples/numbers/finding_if_prime.py b/src/neat_builtin_examples/numbers/finding_if_prime.py deleted file mode 100644 index 2c2c447..0000000 --- a/src/neat_builtin_examples/numbers/finding_if_prime.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -import math -import random - -def finding_prime(number): - ''' find whether a number is prime in a simple way''' - num = abs(number) - if num < 4 : return True - for x in range(2, num): - if num % x == 0: - return False - return True - - -def finding_prime_sqrt(number): - ''' find whether a number is prime as soon as it rejects all candidates up to sqrt(n) ''' - num = abs(number) - if num < 4 : return True - for x in range(2, int(math.sqrt(num)) + 1): - if number % x == 0: - return False - return True - - -def finding_prime_fermat(number): - ''' find whether a number is prime with Fermat's theorem, using probabilistic tests ''' - if number <= 102: - for a in range(2, number): - if pow(a, number- 1, number) != 1: - return False - return True - else: - for i in range(100): - a = random.randint(2, number - 1) - if pow(a, number - 1, number) != 1: - return False - return True - - - -def test_finding_prime(): - number1 = 17 - number2 = 20 - assert(finding_prime(number1) == True) - assert(finding_prime(number2) == False) - assert(finding_prime_sqrt(number1) == True) - assert(finding_prime_sqrt(number2) == False) - assert(finding_prime_fermat(number1) == True) - assert(finding_prime_fermat(number2) == False) - print('Tests passed!') - - -if __name__ == '__main__': - test_finding_prime() - - diff --git a/src/neat_builtin_examples/numbers/generate_prime.py b/src/neat_builtin_examples/numbers/generate_prime.py deleted file mode 100644 index a008b4c..0000000 --- a/src/neat_builtin_examples/numbers/generate_prime.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -import math -import random -import sys -from finding_prime import finding_prime_sqrt - - -def generate_prime(number=3): - ''' return a n-bit prime ''' - while 1: - p = random.randint(pow(2, number-2), pow(2, number-1)-1) - p = 2 * p + 1 - if finding_prime_sqrt(p): - return p - - -if __name__ == '__main__': - if len(sys.argv) < 2: - print ("Usage: generate_prime.py number") - sys.exit() - else: - number = int(sys.argv[1]) - print(generate_prime(number)) - - - - - - - - - diff --git a/src/neat_builtin_examples/numbers/testing_numpy_speed.py b/src/neat_builtin_examples/numbers/testing_numpy_speed.py deleted file mode 100644 index 714b3b4..0000000 --- a/src/neat_builtin_examples/numbers/testing_numpy_speed.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python -# mari von steinkirch @2013 -# steinkirch at gmail - -import numpy -import time - -def trad_version(): - t1 = time.time() - X = range(10000000) - Y = range(10000000) - Z = [] - for i in range(len(X)): - Z.append(X[i] + Y[i]) - return time.time() - t1 - -def numpy_version(): - t1 = time.time() - X = numpy.arange(10000000) - Y = numpy.arange(10000000) - Z = X + Y - return time.time() - t1 - -if __name__ == '__main__': - print(trad_version()) - print(numpy_version()) - - -''' -3.23564291 -0.0714290142059 -''' diff --git a/src/neat_builtin_examples/sets/bit_operations/clear_bits.py b/src/neat_builtin_examples/sets/bit_operations/clear_bits.py deleted file mode 100644 index e5802cd..0000000 --- a/src/neat_builtin_examples/sets/bit_operations/clear_bits.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Clear a bit in a binary number. It is almost like the reverse of set bit: - 1) first create a number filled of 1s, with 0 at i (can create 0001000 and ~) - 2) AND the number so it clears the ith bit - - >>> num = int('10010000', 2) - >>> clear_bit(num, 4) - '0b10000000' - >>> num = int('10010011', 2) - >>> clear_all_bits_from_i_to_0(num, 2) - '0b10010000' - >>> num = int('1110011', 2) - >>> clear_all_bits_from_most_sig_to_1(num, 2) - '0b11' -''' - - - -def clear_bit(num, i): - mask = ~ (1 << i) # -0b10001 - return bin(num & mask) - - -def clear_all_bits_from_i_to_0(num, i): - mask = ~ ( (1 << (i+1)) - 1) - return bin(num & mask) - - -def clear_all_bits_from_most_sig_to_1(num, i): - mask = ( 1 << i) -1 - return bin(num & mask) - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/sets/bit_operations/get_bit.py b/src/neat_builtin_examples/sets/bit_operations/get_bit.py deleted file mode 100644 index a32c71e..0000000 --- a/src/neat_builtin_examples/sets/bit_operations/get_bit.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Get a bit in a binary number: - 1) Shifts 1 over by i bits - 2) make an AND with the number - 3) all the other than the bit at i are clean, now compare to 0 - 4) if the new value is not 0, bit i is 1 - >>> num = int('0100100', 2) - >>> get_bit(num, 0) - 0 - >>> get_bit(num, 1) - 0 - >>> get_bit(num, 2) - 1 - >>> get_bit(num, 3) - 0 - >>> get_bit(num, 4) - 0 - >>> get_bit(num, 5) - 1 - >>> get_bit(num, 6) - 0 -''' - - - -def get_bit(num, i): - mask = 1 << i - return num & mask != 0 - - - - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/sets/bit_operations/set_bit.py b/src/neat_builtin_examples/sets/bit_operations/set_bit.py deleted file mode 100644 index 3f98336..0000000 --- a/src/neat_builtin_examples/sets/bit_operations/set_bit.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Set a bit in a binary number: - 1) Shifts 1 over by i bits - 2) make an OR with the number, only the value at bit i will change and all the others bit - of the mask are zero so will not affect the num - >>> num = int('0100100', 2) - >>> set_bit(num, 0) - '0b100101' - >>> set_bit(num, 1) - '0b100110' - >>> set_bit(num, 2) # nothing change - '0b100100' - >>> set_bit(num, 3) - '0b101100' - >>> set_bit(num, 4) - '0b110100' - >>> set_bit(num, 5) # nothing change - '0b100100' -''' - - - -def set_bit(num, i): - mask = 1 << i - return bin( num | mask ) - - - - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/neat_builtin_examples/sets/removing_duplicates_seq_.py b/src/neat_builtin_examples/sets/removing_duplicates_seq_.py deleted file mode 100644 index 9399ae3..0000000 --- a/src/neat_builtin_examples/sets/removing_duplicates_seq_.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def removing_duplicates_seq(seq): - ''' if the values are hashable, we can use set and generators to remove duplicates - in a sequence ''' - seen = set() - for item in seq: - if item not in seen: - yield item - seen.add(item) - -def removing_duplicates_seq_not_hash(seq, key= None): - ''' if the item is not hashable, such as dictionaries ''' - seen = set() - for item in seq: - val = item if key is None else key[item] - if item not in seen: - yield item - seen.add(val) - - - -def test_removing_duplicates_seq(): - seq = [1, 2, 2, 2, 3, 3, 4, 4, 4] - dict = {'a':1, 'b':2, 'a':2, 'a':1} - assert(list(removing_duplicates_seq(seq)) == [1,2,3,4]) - assert(list(removing_duplicates_seq_not_hash(dict)) == ['a', 'b']) - print('Tests passed!'.center(20, '*')) - - -if __name__ == '__main__': - test_removing_duplicates_seq() - - diff --git a/src/neat_builtin_examples/sets/set_operations_dict.py b/src/neat_builtin_examples/sets/set_operations_dict.py deleted file mode 100644 index af68b31..0000000 --- a/src/neat_builtin_examples/sets/set_operations_dict.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -from collections import OrderedDict - -def set_operations_with_dict(): - ''' find common in 2 dictionaries ''' - ''' values() do not support set operations!''' - - pairs = [('a', 1), ('b',2), ('c',3)] - d1 = OrderedDict(pairs) - print(d1) # ('a', 1), ('b', 2), ('c', 3) - - d2 = {'a':1, 'c':2, 'd':3, 'e':4} - print(d2) # {'a': 1, 'c': 2, 'e': 4, 'd': 3} - - union = d1.keys() & d2.keys() - print(union) # {'a', 'c'} - - union_items = d1.items() & d2.items() - print(union_items) # {('a', 1)} - - subtraction1 = d1.keys() - d2.keys() - print(subtraction1) # {'b'} - - subtraction2 = d2.keys() - d1.keys() - print(subtraction2) # {'d', 'e'} - - subtraction_items = d1.items() - d2.items() - print(subtraction_items) # {('b', 2), ('c', 3)} - - ''' we can remove keys from a dict doing: ''' - d3 = {key:d2[key] for key in d2.keys() - {'c', 'd'}} - print(d3) {'a': 1, 'e': 4} - -if __name__ == '__main__': - set_operations_with_dict() - diff --git a/src/neat_builtin_examples/sets/set_operations_with_dict.py b/src/neat_builtin_examples/sets/set_operations_with_dict.py deleted file mode 100644 index af68b31..0000000 --- a/src/neat_builtin_examples/sets/set_operations_with_dict.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -from collections import OrderedDict - -def set_operations_with_dict(): - ''' find common in 2 dictionaries ''' - ''' values() do not support set operations!''' - - pairs = [('a', 1), ('b',2), ('c',3)] - d1 = OrderedDict(pairs) - print(d1) # ('a', 1), ('b', 2), ('c', 3) - - d2 = {'a':1, 'c':2, 'd':3, 'e':4} - print(d2) # {'a': 1, 'c': 2, 'e': 4, 'd': 3} - - union = d1.keys() & d2.keys() - print(union) # {'a', 'c'} - - union_items = d1.items() & d2.items() - print(union_items) # {('a', 1)} - - subtraction1 = d1.keys() - d2.keys() - print(subtraction1) # {'b'} - - subtraction2 = d2.keys() - d1.keys() - print(subtraction2) # {'d', 'e'} - - subtraction_items = d1.items() - d2.items() - print(subtraction_items) # {('b', 2), ('c', 3)} - - ''' we can remove keys from a dict doing: ''' - d3 = {key:d2[key] for key in d2.keys() - {'c', 'd'}} - print(d3) {'a': 1, 'e': 4} - -if __name__ == '__main__': - set_operations_with_dict() - diff --git a/src/neat_builtin_examples/tuples/namedtuple_example.py b/src/neat_builtin_examples/tuples/namedtuple_example.py deleted file mode 100644 index c2b23d1..0000000 --- a/src/neat_builtin_examples/tuples/namedtuple_example.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -from collections import namedtuple - -def namedtuple_example(): - ''' show some examples for namedtuple ''' - sunnydale = namedtuple('name', ['job', 'age']) - buffy = sunnydale('slayer', '17') - print(buffy.job) - - -if __name__ == '__main__': - namedtuple_example() - - diff --git a/src/programming_paradigms/dynamic_programming/__init__.py b/src/programming_paradigms/dynamic_programming/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/programming_paradigms/modules/__init__.py b/src/programming_paradigms/modules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/programming_paradigms/modules/fib_generator.py b/src/programming_paradigms/modules/fib_generator.py deleted file mode 100644 index b4b812f..0000000 --- a/src/programming_paradigms/modules/fib_generator.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -def fib_generator(): - a, b = 0, 1 - while True: - yield b - a, b = b, a+b - - -if __name__ == '__main__': - fib = fib_generator() - print(next(fib)) - print(next(fib)) - print(next(fib)) - print(next(fib)) diff --git a/src/programming_paradigms/modules/import_pickle.py b/src/programming_paradigms/modules/import_pickle.py deleted file mode 100644 index 9aa3ce5..0000000 --- a/src/programming_paradigms/modules/import_pickle.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -import pickle - -def import_pickle(filename): - """ an example of using pickle for importing data from files """ - fh = None - try: - fh = open(filename, "rb") - mydict2 = pickle.load(fh) - return mydict2 - - except (EnvironmentError) as err: - print ("{0}: import error: {0}".format(os.path.basename(sys.arg[0]), err)) - return false - - finally: - if fh is not None: - fh.close() - - -def test_import_pickle(): - pkl_file = 'test.dat' - mydict = import_pickle(pkl_file) - print(mydict) - - -if __name__ == '__main__': - test_import_pickle() diff --git a/src/programming_paradigms/modules/passing_cmd_line_args.py b/src/programming_paradigms/modules/passing_cmd_line_args.py deleted file mode 100644 index 4a05b66..0000000 --- a/src/programming_paradigms/modules/passing_cmd_line_args.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - - -import sys - -def main(): - ''' print command line arguments ''' - for arg in sys.argv[1:]: - print arg - -if __name__ == "__main__": - main() - - - - diff --git a/src/programming_paradigms/oop/__init__.py b/src/programming_paradigms/oop/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/searching_and_sorting/searching/__init__.py b/src/searching_and_sorting/searching/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/searching_and_sorting/searching/binary_search.py b/src/searching_and_sorting/searching/binary_search.py deleted file mode 100644 index 9bca2f4..0000000 --- a/src/searching_and_sorting/searching/binary_search.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - - -def binary_search(seq, key): - ''' binary search iterative algorithm ''' - ''' observe that the index is returned ''' - hi = len(seq) - lo = 0 - while lo < hi: - mid = (hi+lo) // 2 - if seq[mid] == key: - return mid - elif key < seq[mid]: - hi = mid - else: - lo = mid + 1 - - -def binary_search_rec(seq, key, lo=0, hi=None): - ''' binary search recursive algorithm ''' - hi = hi or len(seq) - if hi < lo: return None - mid = (hi + lo) // 2 - if seq[mid] == key: - return mid - elif seq[mid] < key: - return binary_search_rec(seq, key, mid + 1, hi) - else: - return binary_search_rec(seq, key, lo, mid - 1) - - -def test_binary_search(): - seq = [1,2,5,6,7,10,12,12,14,15] - key = 6 - assert(binary_search(seq, key) == 3) - assert(binary_search_rec(seq, key) == 3) - print('Tests passed!') - - -if __name__ == '__main__': - test_binary_search() - - - - diff --git a/src/searching_and_sorting/searching/binary_search_matrix.py b/src/searching_and_sorting/searching/binary_search_matrix.py deleted file mode 100644 index 5408e93..0000000 --- a/src/searching_and_sorting/searching/binary_search_matrix.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -''' Searches an element in a matrix where in every row, the values are increasing from left to right, but the last number in a row is smaller than the first number in the next row. - - (1) The naive brute force solution (sequential search) scan all numbers and cost O(nm). However, since the numbers are already sorted, the matrix can be viewed as a 1D sorted array. The binary search algorithm is suitable. The efficiency is O(logmn). - - >>> m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] - >>> binary_search_matrix_rec(m, 6) - (1, 2) - >>> binary_search_matrix_rec(m, 12) - >>> binary_search_matrix_iter(m, 6) - (1, 2) - >>> binary_search_matrix_iter(m, 12) - >>> binary_search_matrix_iter(m, 1) - (0, 0) - - (2) Another solution is "discarding" arrays in the way. The efficiency is O(logm). - >>> m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] - >>> searching_matrix(m, 6) - (1, 2) - >>> searching_matrix(m, 12) - -''' - - -def binary_search_matrix_rec(m, key, lo=0, hi=None): - if not m: return None - rows = len(m) - cols = len(m[0]) - hi = hi or rows*cols - if hi > lo: # -----> REMEMBER THIS OR INDEX WILL EXPLODE!!!!!!!! - mid = (hi + lo)//2 - row = mid//cols - col = mid%cols - item = m[row][col] - if key == item: return row, col - elif key < item: return binary_search_matrix_rec(m, key, lo, mid-1) - else: return binary_search_matrix_rec(m, key, mid+1, hi) - return None - - - -def binary_search_matrix_iter(m, key): - if not m: return None - rows = len(m) - cols = len(m[0]) - lo, hi = 0, rows*cols - while lo < hi: - mid = (hi + lo)//2 - row = mid//rows - col = mid%rows - item = m[row][col] - if key == item: return (row, col) - elif key < item: hi = mid - else: lo = mid +1 - return None - - -def searching_matrix(m, key): - if not m: return None - rows = len(m) - cols = len(m[0]) - i, j = 0, cols -1 - while i < rows and j > 0: - item = m[i][j] - if key == item: return (i, j) - elif key < item: j -= 1 - else: i += 1 - return None - - -if __name__ == '__main__': - import doctest - doctest.testmod() diff --git a/src/searching_and_sorting/searching/interserction_two_arrays.py b/src/searching_and_sorting/searching/interserction_two_arrays.py deleted file mode 100644 index 485634a..0000000 --- a/src/searching_and_sorting/searching/interserction_two_arrays.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - - -''' using sets ''' - -def intersection_two_arrays_sets(seq1, seq2): - ''' find the intersection of two arrays using set proprieties ''' - set1 = set(seq1) - set2 = set(seq2) - return set1.intersection(set2) #same as list(set1 & set2 - - - -''' using merge sort ''' - -def intersection_two_arrays_ms(seq1, seq2): - ''' find the intersection of two arrays using merge sort ''' - res = [] - while seq1 and seq2: - if seq1[-1] == seq2[-1]: - res.append(seq1.pop()) - seq2.pop() - elif seq1[-1] > seq2[-1]: - seq1.pop() - else: - seq2.pop() - res.reverse() - return res - - - - -''' using binary search ''' - -def binary_search(seq, key, lo=0, hi=None): - ''' binary search iterative algorithm ''' - hi = hi or len(seq) - while lo < hi: - mid = (hi+lo) // 2 - if seq[mid] == key: - return True - elif key > seq[mid]: - lo = mid + 1 - else: - hi = mid - return None - -def intersection_two_arrays_bs(seq1, seq2): - ''' if A small and B is too large, we can do a binary search on each entry in B ''' - ''' only works if sorted and the small sequence has not larger nmbers!!!''' - if len(seq1) > len(seq2): seq, key = seq1, seq2 - else: seq, key = seq2, seq1 - - intersec = [] - for item in key: - if binary_search(seq, item): - intersec.append(item) - return intersec - - - -def test_intersection_two_arrays(module_name='this module'): - seq1 = [1,2,3,5,7,8] - seq2 = [3,5,6] - - assert(set(intersection_two_arrays_sets(seq1,seq2)) == set([3,5])) - assert(intersection_two_arrays_bs(seq1,seq2) == [3,5]) - assert(intersection_two_arrays_ms(seq1,seq2) == [3,5]) - - s = 'Tests in {name} have {con}!' - print(s.format(name=module_name, con='passed')) - - -if __name__ == '__main__': - test_intersection_two_arrays() - diff --git a/src/searching_and_sorting/sorting/__init__.py b/src/searching_and_sorting/sorting/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/searching_and_sorting/sorting/merge_sort.py b/src/searching_and_sorting/sorting/merge_sort.py deleted file mode 100644 index 5a099c0..0000000 --- a/src/searching_and_sorting/sorting/merge_sort.py +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - - -''' Some examples of how to implement Merge Sort in Python. - --> RUNTIME: WORST/BEST/AVERAGE Is O(nlogn) - --> space complexity is O(n) for arrays - --> in general not in place, good for large arrays - --> In the case of two arrays: we can merge two arrays using the merge function from the merge sort - --> we can do this for files too, merging each two - - 1) If we can modify the arrays (pop) we can use: - def merge(left, right): - if not left or not right: return left or right # nothing to be merged - result = [] - while left and right: - if left[-1] >= right[-1]: - result.append(left.pop()) - else: - result.append(right.pop()) - result.reverse() - return (left or right) + result - - - 2) If we can't modify or we want to in place, we need two pointers: - >>> l1 = [1, 2, 3, 4, 5, 6, 7] - >>> l2 = [2, 4, 5, 8] - >>> merge(l1, l2) - [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8] - - - 3) For example, in the case we have a big array filled 0s in the end, and another array with the size of the number of 0s: - >>> l1 = [1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0] - >>> l2 = [2, 4, 5, 8] - >>> merge_two_arrays_inplace(l1, l2) - [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8] - - - 4) If we want to merge sorted files (and we have plenty of RAM to load all files): - >>> list_files = ['1.dat', '2.dat', '3.dat'] - >>> merge_files(list_files) - [1, 1, 2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 8] -''' - - - - -""" - The typical example... -""" - -def merge_sort(seq): - if len(seq) < 2: - return seq - mid = len(seq)//2 - lft, rgt = seq[:mid], seq[mid:] - if len(lft)>1: - lft = merge_sort(lft) - if len(rgt)>1: - rgt = merge_sort(rgt) - - res = [] - while lft and rgt: - if lft [-1]>= rgt[-1]: - res.append(lft.pop()) - else: - res.append(rgt.pop()) - res.reverse() - return(lft or rgt) + res - - - - -''' - We could also divide this sort into two parts, separating - the merge part in another function -''' - -def merge_sort_sep(seq): - if len(seq) < 2 : - return seq # base case - mid = len(seq)//2 - left = merge_sort(seq[:mid]) - right = merge_sort(seq[mid:]) # notice that mid is included! - return merge(left, right) # merge iteratively - - - -def merge(left, right): - if not left or not right: - return left or right # nothing to be merged - result = [] - i, j = 0, 0 - while i < len(left) and j < len(right): - if left[i] <= right[j]: - result.append(left[i]) - i += 1 - else: - result.append(right[j]) - j += 1 - if left[i:] : result.extend(left[i:]) # REMEMBER TO EXTEND, NOT APPEND - if right[j:] : result.extend(right[j:]) - return result - - - - -''' The following merge functions is O(2n) and - illustrate many features in Python that ''' -def merge_2n(left, right): - if not left or not right: return left or right # nothing to be merged - result = [] - while left and right: - if left[-1] >= right[-1]: - result.append(left.pop()) - else: - result.append(right.pop()) - result.reverse() - return (left or right) + result - - - -''' Merge two arrays in place ''' -def merge_two_arrays_inplace(l1, l2): - if not l1 or not l2: return l1 or l2 # nothing to be merged - p2 = len(l2) - 1 - p1 = len(l1) - len(l2) - 1 - p12 = len(l1) - 1 - while p2 >= 0 and p1 >= 0: - item_to_be_merged = l2[p2] - item_bigger_array = l1[p1] - if item_to_be_merged < item_bigger_array: - l1[p12] = item_bigger_array - p1 -= 1 - else: - l1[p12] = item_to_be_merged - p2 -= 1 - p12 -= 1 - return l1 - - - -''' Merge sort for files ''' -def merge_files(list_files): - result = [] - final = [] - for filename in list_files: - aux = [] - with open(filename, 'r') as file: - for line in file: - aux.append(int(line)) - result.append(aux) - final.extend(result.pop()) - for l in result: - final = merge(l, final) - return final - - - - - -def test_merge_sort(): - seq = [3, 5, 2, 6, 8, 1, 0, 3, 5, 6, 2] - seq_sorted = sorted(seq) - assert(merge_sort(seq) == seq_sorted) - assert(merge_sort_sep(seq) == seq_sorted) - print('Tests passed!') - - -if __name__ == '__main__': - test_merge_sort() diff --git a/src/searching_and_sorting/sorting/quick_sort.py b/src/searching_and_sorting/sorting/quick_sort.py deleted file mode 100644 index 39d1d90..0000000 --- a/src/searching_and_sorting/sorting/quick_sort.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -''' Some examples of how to implement Quick Sort in Python - --> RUNTIME: BEST/AVERAGE Is O(nlogn), WORST is O(n2) - --> the first example is not in place, the second is in place - --> test with two element arrays, identical values - - Quick sort in place: - 1) select pivot as the index = 0 - 2) start pointer1 at index = 1 and pointer2 in the last element - 3) while pointer1 < pointer2: - if value in pointer1 <= pivot - swap value in pointer1 with value in pointer2 and advanced pointer2 - else - advance pointer1 - 4) now the array is like this: - [pivot, larger than pivot, smaller than pivot] - 5) swap the pivot where pointer 1 stop - 6) do recursively for [smaller] + [pivot] + [larger] -''' - - - - -def quick_sort(seq): - if len(seq) < 2 : return seq - mid = len(seq)//2 - pi = seq[mid] - seq = seq[:mid] + seq[mid+1:] - left = quick_sort([x for x in seq if x <= pi]) # REMEMBER TO INCLUDE X (OR IN RIGHT) - right = quick_sort([x for x in seq if x > pi]) - return left + [pi] + right - - - - -""" we can also divide them into two functions """ -def partition(seq): - pi,seq = seq[0],seq[1:] - lo = [x for x in seq if x <= pi] - hi = [x for x in seq if x > pi] - return lo, pi, hi - -def quick_sort_divided(seq): - if len(seq) < 2: return seq - lo, pi, hi = partition(seq) - return quick_sort_divided(lo) + [pi] + quick_sort_divided(hi) - - -''' quick_sort in place ''' -def quick_sort_in(seq): - if len(seq) < 2 : return seq - if len(seq) == 2 and seq[0] > seq[1]: - seq[0], seq[1] = seq[1], seq[0] # problems when only 2 elements because of swap - pivot = seq[0] # start at the ends because we don't know how many elements - p1, p2 = 1, len(seq) -1 # set pointers at both ends - while p1 < p2: # must be < or out of range - if seq[p1] <= pivot: # must be <= because of pivot swap - seq[p1], seq[p2] = seq[p2], seq[p1] - p2 -= 1 - else: - p1 += 1 - seq[0], seq[p1] = seq[p1], pivot - return quick_sort_in(seq[p1+1:]) + [seq[p1]] + quick_sort_in(seq[:p1]) - - - - -def test_quick_sort(): - seq = [3, 5, 2, 6, 8, 1, 0, 3, 5, 6, 2] - assert(quick_sort(seq) == sorted(seq)) - assert(quick_sort_divided(seq) == sorted(seq)) - print('Tests passed!') - - -if __name__ == '__main__': - test_quick_sort() - - - diff --git a/src/searching_and_sorting/sorting/sort_anagrams_together.py b/src/searching_and_sorting/sorting/sort_anagrams_together.py deleted file mode 100644 index 890a7b8..0000000 --- a/src/searching_and_sorting/sorting/sort_anagrams_together.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - -''' A method to sort an array so that all the anagrams are together. Since we only - want the anagrams to be grouped, we can use a dictionary for this task. This - algorithm is O(n). - >>> l1 = ['hat', 'ball', 'tha', 'cut', 'labl', 'hta', 'cool', 'cuy', 'uct'] - >>> sort_anagrams_together(l1) - ['cut', 'uct', 'cool', 'ball', 'labl', 'hat', 'tha', 'hta', 'cuy'] -''' - -from collections import defaultdict -def sort_anagrams_together(l1): - result = [] - - # step 1 save the anagrams together - dict_aux = defaultdict(list) # rememebr to indicate the type - for word in l1: - key = ''.join(sorted(word)) # need to sort the strings and join it - dict_aux[key].append(word) # because only sorted give a list of each char - - # step 2 print the anagrams. Note that if you want everything - # sorted you would have to sort the keys and insert the angrams after that - for key in dict_aux: - result.extend(dict_aux[key]) - - return result - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/trees/__init__.py b/src/trees/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/trees/binary_search_tree.py b/src/trees/binary_search_tree.py deleted file mode 100644 index da35caf..0000000 --- a/src/trees/binary_search_tree.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -from binary_tree import NodeBT, BinaryTree - - -class NodeBST(NodeBT): - - def __init__(self, item=None, level=0): - self.item = item - self.level = level - self.left = None - self.right = None - - - def _addNextNode(self, value, level_here=1): - new_node = NodeBST(value, level_here) - if not self.item: - self.item = new_node - else: - if value > self.item: - self.right = self.right and self.right._addNextNode(value, level_here+1) or new_node - elif value < self.item: - self.left = self.left and self.left._addNextNode(value, level_here+1) or new_node - else: - print("BSTs do not support repeated items.") - return self # this is necessary!!! - - - - def _searchForNode(self, value): - if self.item == value: - return self - elif self.left and value < self.item: - return self.left._searchForNode(value) - elif self.right and value > self.item: - return self.right._searchForNode(value) - else: - return False - - - -class BinarySearchTree(BinaryTree): - - def __init__(self): - self.root = None - - def addNode(self, value): - if not self.root: - self.root = NodeBST(value) - else: - self.root._addNextNode(value) - - - - -if __name__ == '__main__': - bst = BinarySearchTree() - print "Adding nodes 1 to 10 in the tree..." - for i in range(1, 10): - bst.addNode(i) - print "Is 8 a leaf? ", bst.isLeaf(8) - print "Whats the level of node 8? ", bst.getNodeLevel(8) - print "Is node 10 a root? ", bst.isRoot(10) - print "Is node 1 a root? ", bst.isRoot(1) - print "Whats the tree height? ", bst.getHeight() - print "Is this tree BST? ", bst.isBST() - print "Is this tree balanced? ", bst.isBalanced() - - diff --git a/src/trees/binary_tree.py b/src/trees/binary_tree.py deleted file mode 100644 index 31f0102..0000000 --- a/src/trees/binary_tree.py +++ /dev/null @@ -1,206 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - - -''' Implementation of a binary tree and its properties. For example, the following bt: - - 1 ---> level 0 - 2 3 ---> level 1 - 4 5 ---> level 2 - 6 7 ---> level 3 - 8 9 ---> level 4 - - has the following properties: - - - SIZE OR NUMBER OF NODES: n = 9 - - NUMBER OF BRANCHES OR INTERNAL NODES: b = n-1 = 8 - - VALUE OF ROOT = 1 - - MAX_DEPTH OR HEIGHT: h = 4 - - IS BALANCED? NO - - IS BST? NO -''' - - -class NodeBT(object): - def __init__(self, item=None, level=0): - self.item = item - self.level = level - self.left = None - self.right = None - - - def __repr__(self): - return '{}'.format(self.item) - - - def _addNextNode(self, value, level_here=1): - new_node = NodeBT(value, level_here) - if not self.item: - self.item = new_node - elif not self.left: - self.left = new_node - elif not self.right: - self.right = new_node - else: - self.left = self.left._addNextNode(value, level_here+1) - return self ## this is important, because the node return to the main - - - def _searchForNode(self, value): - if self.item == value: - return self - else: - found = None - if self.left: - found = self.left._searchForNode(value) - if self.right: - found = found or self.right._searchForNode(value) - return found - - - def _isLeaf(self): - return not self.right and not self.left - - - def _getMaxHeight(self): - ''' Get the max height at the node, O(n)''' - levelr, levell = 0, 0 - if self.right: - levelr = self.right._getMaxHeight() + 1 - if self.left: - levell = self.left._getMaxHeight() + 1 - return max(levelr, levell) - - - def _getMinHeight(self, level=0): - ''' Get the min height at the node, O(n)''' - levelr, levell = -1, -1 - if self.right: - levelr = self.right._getMinHeight(level +1) - if self.left: - levell = self.left._getMinHeight(level +1) - return min(levelr, levell) + 1 - - - def _isBalanced(self): - ''' Find whether the tree is balanced, by calculating heights first, O(n2) ''' - if self._getMaxHeight() - self._getMinHeight() < 2: - return False - else: - if self._isLeaf(): - return True - elif self.left and self.right: - return self.left._isBalanced() and self.right._isBalanced() - elif not self.left and self.right: - return self.right._isBalanced() - elif not self.right and self.left: - return self.left._isBalanced() - - def _isBST(self, mintree=None, maxtree=None): - ''' Find whether the tree is a BST, inorder ''' - if self.item: - if not mintree: - mintree = self.item - if not maxtree: - maxtree = self.item - - if self._isLeaf(): - return True - elif self.left: - if self.left.item < self.item and mintree > self.left.item: - mintree = self.left.item - return self.left._isBST(mintree, maxtree) - else: - return False - elif self.right: - if self.right.item > self.item and maxtree < self.right.item: - maxtree = self.right.item - return self.right._isBST(mintree, maxtree) - else: - return False - else: - print('Tree is empty') - - - - - - - - -class BinaryTree(object): - - def __init__(self): - self.root = None - - - def addNode(self, value): - if not self.root: - self.root = NodeBT(value) - else: - self.root._addNextNode(value) - - - def isLeaf(self, value): - node = self.root._searchForNode(value) - if node: - return node._isLeaf() - else: - print "Node not found." - - - def getNodeLevel(self, item): - node = self.root._searchForNode(item) - if node: - return node.level - else: - print('Node not found') - - - def isRoot(self, value): - return self.root.item == value - - - def getHeight(self): - return self.root._getMaxHeight() - - - def isBalanced(self): - return self.root._isBalanced() - - - def isBST(self): - return self.root._isBST() - - - def preorder(self): - current = self.root - nodes, stack = [], [] - while stack or current: - if current: - nodes.append(current.item) # thats what change - stack.append(current) - current = current.left - else: - current = stack.pop() - current = current.right - return nodes - - - -if __name__ == '__main__': - bt = BinaryTree() - print "Adding nodes 1 to 10 in the tree..." - for i in range(1, 10): - bt.addNode(i) - print "Is 8 a leaf? ", bt.isLeaf(8) - print "Whats the level of node 8? ", bt.getNodeLevel(8) - print "Is node 10 a root? ", bt.isRoot(10) - print "Is node 1 a root? ", bt.isRoot(1) - print "Whats the tree height? ", bt.getHeight() - print "Is this tree BST? ", bt.isBST() - print "Is this tree balanced? ", bt.isBalanced() - print (bt.preorder()) \ No newline at end of file diff --git a/src/trees/transversal_BST_ancestor.py b/src/trees/transversal_BST_ancestor.py deleted file mode 100644 index 9be8c92..0000000 --- a/src/trees/transversal_BST_ancestor.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - -''' find the lowest ancestor in a BST ''' - -from transversal_BST_recursively import BSTwithTransversalRecursively - - - -def find_ancestor(path, low_value, high_value): - while path: - current_value = path[0] - if current_value < low_value: - try: - path = path[2:] - except: - return current_value - elif current_value > high_value: - try: - path = path[1:] - except: - return current_value - elif low_value <= current_value <= high_value: - return current_value - else: - return None # this is probably never touched - - - - -if __name__ == '__main__': - bst = BSTwithTransversalRecursively() - l = [10, 5, 15, 1, 6, 11, 50] - for i in l: - bst.addNode(i) - path = bst.preorder() - print("The path inorder: ", path) - - print("The path between 1 and 6 is :", find_ancestor(path, 1, 6)) - print("The path between 1 and 11 is: ", find_ancestor(path, 1, 11)) - print("The path between 11 and 50 is: ", find_ancestor(path, 11, 50)) - print("The path between 5 and 15 is: ", find_ancestor(path, 5, 15)) \ No newline at end of file diff --git a/src/trees/transversal_BST_iteratively.py b/src/trees/transversal_BST_iteratively.py deleted file mode 100644 index 4cbba51..0000000 --- a/src/trees/transversal_BST_iteratively.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -from collections import deque -from binary_search_tree import BinarySearchTree, NodeBST - - - -class BSTwithTransversalIterative(BinarySearchTree): - - def inorder(self): - current = self.root - nodes, stack = [], [] - while stack or current: - if current: - stack.append(current) - current = current.left - else: - current = stack.pop() - nodes.append(current.item) # thats what change - current = current.right - return nodes - - - def preorder(self): - current = self.root - nodes, stack = [], [] - while stack or current: - if current: - nodes.append(current.item) # thats what change - stack.append(current) - current = current.left - else: - current = stack.pop() - current = current.right - return nodes - - - def preorder2(self): - nodes = [] - stack = [self.root] - while stack: - current = stack.pop() - if current: - nodes.append(current.item) - stack.append(current.right) - stack.append(current.left) - return nodes - - - def BFT(self): - current = self.root - nodes = [] - queue = deque() - queue.append(current) - while queue: - current = queue.popleft() - nodes.append(current.item) - if current.left: - queue.append(current.left) # LEFT FIRST! - if current.right: - queue.append(current.right) - return nodes - - - - - - -if __name__ == '__main__': - - bst = BSTwithTransversalIterative() - l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] - for i in l: - bst.addNode(i) - - print "Is 8 a leaf? ", bst.isLeaf(8) - print "Whats the level of node 8? ", bst.getNodeLevel(8) - print "Is node 10 a root? ", bst.isRoot(10) - print "Is node 1 a root? ", bst.isRoot(1) - print "Whats the tree height? ", bst.getHeight() - print "Is this tree BST? ", bst.isBST() - print "Is this tree balanced? ", bst.isBalanced() - - print("Pre-order I: ", bst.preorder()) - print("Pre-order II: ", bst.preorder2()) - print("In-order: ", bst.inorder()) - print("BFT: ", bst.BFT()) diff --git a/src/trees/transversal_BST_recursively.py b/src/trees/transversal_BST_recursively.py deleted file mode 100644 index a2512f3..0000000 --- a/src/trees/transversal_BST_recursively.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" - - -from binary_search_tree import BinarySearchTree, NodeBST - - - -class BSTwithTransversalRecursively(BinarySearchTree): - - def __init__(self): - self.root = None - self.nodes_BFS = [] - self.nodes_pre = [] - self.nodes_post = [] - self.nodes_in = [] - - def BFT(self): - self.root.level = 0 - queue = [self.root] - current_level = self.root.level - - while len(queue) > 0: - current_node = queue.pop(0) - if current_node.level > current_level: - current_level += 1 - self.nodes_BFS.append(current_node.item) - - if current_node.left: - current_node.left.level = current_level + 1 - queue.append(current_node.left) - - if current_node.right: - current_node.right.level = current_level + 1 - queue.append(current_node.right) - - return self.nodes_BFS - - def inorder(self, node=None, level=0): - if not node and level == 0: - node = self.root - if node: - self.inorder(node.left, level+1) - self.nodes_in.append(node.item) - self.inorder(node.right, level+1) - return self.nodes_in - - def preorder(self, node=None, level=0): - if not node and level == 0: - node = self.root - if node: - self.nodes_pre.append(node.item) - self.preorder(node.left, level+1) - self.preorder(node.right, level+1) - return self.nodes_pre - - def postorder(self, node=None, level=0): - if not node and level == 0: - node = self.root - if node: - self.postorder(node.left, level+1) - self.postorder(node.right, level+1) - self.nodes_post.append(node.item) - return self.nodes_post - - - -if __name__ == '__main__': - - bst = BSTwithTransversalRecursively() - l = [10, 5, 6, 3, 8, 2, 1, 11, 9, 4] - for i in l: - bst.addNode(i) - - print "Is 8 a leaf? ", bst.isLeaf(8) - print "Whats the level of node 8? ", bst.getNodeLevel(8) - print "Is node 10 a root? ", bst.isRoot(10) - print "Is node 1 a root? ", bst.isRoot(1) - print "Whats the tree height? ", bst.getHeight() - print "Is this tree BST? ", bst.isBST() - print "Is this tree balanced? ", bst.isBalanced() - - print("Pre-order: ", bst.preorder()) - print("Post-order: ", bst.postorder()) - print("In-order: ", bst.inorder()) - print("BFT: ", bst.BFT()) \ No newline at end of file diff --git a/stacks/README.md b/stacks/README.md new file mode 100644 index 0000000..5b877c9 --- /dev/null +++ b/stacks/README.md @@ -0,0 +1,42 @@ +## stacks + + +
+ +* stacks are **last in, first out** (LIFO) abstract structures, where the newest element is first one to be removed from the structure. + +* a stack support `push` and `pop` at `O(1)`, and they be implemented with arrays or singly linked list. + +* stacks are useful in **depth-first search** algorithms, where you can push temp data as you recurse, and remove them from the (memory or data structure) stack as you backtrace. + +* to keep `find_min()` at `O(1)`, you can keep track of "prior minimum" when pushing and poping: + +
+ +```python +class Stack: + + def __init__(self): + self.stack = [] + self.min = None + + def push(self, val: int) -> None: + self.stack.append((val, self.min)) + if self.min is not None: + self.min = min(self.min, val) + else: + self.min = val + + def pop(self) -> None: + if self.stack: + (val, prior_min) = self.stack.pop() + self.min = prior_min + return val + + def top(self) -> int: + if self.stack: + return self.stack[-1][0] + + def get_min(self) -> int: + return self.min + ``` diff --git a/stacks/stack.py b/stacks/stack.py new file mode 100644 index 0000000..f805b72 --- /dev/null +++ b/stacks/stack.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Stack: + + def __init__(self): + self.stack = [] + self.min = None + + def push(self, val: int) -> None: + self.stack.append((val, self.min)) + if self.min is not None: + self.min = min(self.min, val) + else: + self.min = val + + def pop(self) -> None: + if self.stack: + (val, prior_min) = self.stack.pop() + self.min = prior_min + return val + + def top(self) -> int: + if self.stack: + return self.stack[-1][0] + + def get_min(self) -> int: + return self.min + diff --git a/trees/README.md b/trees/README.md new file mode 100644 index 0000000..eb9ede1 --- /dev/null +++ b/trees/README.md @@ -0,0 +1,903 @@ +## trees + +
+ +* a tree is an undirected and connected acyclic graph with no cycle or loops. + +* trees are widely used abstract data type that represents a hierarchical structure with a set of connected nodes. + +* each node in the tree can be connected to many children, but must be connected to exactly one parent (except for the root node). + + + +
+ +--- + +### binary trees + +
+ +* **binary trees** are trees that have up to two children. + +* `search`, `remove`, and `insert` are all `O(log(N)` runtime. + +* the space complexity of traversing balanced trees is `O(h)` where `h` is the height of the tree (while very skewed trees will be `O(N)`). + +* the **width** of a binary tree is the number of nodes in a level. + +* the **degree** of a binary tree is the number of children of a node. + + +
+ +--- + +### full, complete, and perfect binary trees + +
+ +* a **full binary tree** has each node with either zero or two children, i.e., no node has only one child. + +* a **complete tree** is a tree on which every level is fully filled (except perhaps for the last). + +* a **perfect tree** is both full and complete (it must have exactly `2^k - 1` nodes, where `k` is the number of levels). + +
+ +```python +def is_full(node): + + if node is None: + return True + + return bool(node.right and node.left) and is_full(node.right) and is_full(node.left) +``` + +
+ +* a node is called **leaf** if it has no children. + +
+ +```python +def is_leaf(node): + + return bool(not node.right and not node.left) +``` + +
+ + +---- + +### depth of a binary tree + +
+ +* the **depth** (or level) of a node is the number of edges from the tree's root node until a certain node. + +* the **height of tree** is the height of its root node, or the depth of its deepest node. + +
+ +```python +def max_depth(root) -> int: + + if root is None: + return -1 + + return 1 + max(height(root.left), height(root.right)) +``` + +
+ +--- + +### balanced trees + +
+ +* a **balanced tree** is a binary tree in which the left and right subtrees of every node differ in height by no more than 1. + +
+ +```python +def is_balanced(root): + + if root is None: + return True + + return abs(height(root.left) - height(root.right)) < 2 and \ + is_balanced(root.left) and is_balanced(root.right) +``` + +
+ +--- + +### tree traversal: breath-first search (level-order) + +
+ +* bfs gives all elements **in order** with time `O(log(N)` and it's used to traverse a tree by level. + +* iterative solutions use a queue for traversal or find the shortest path from the root node to a target node: + - in the first round, it processes the root node. + - in the second round, it processes the nodes next to the root node. + - in the third round, it processes the nodes which are two steps from the root node, etc. + - newly-added nodes will not be traversed immediately but will be processed in the next round. + - if node `X` is added to the `kth` round queue, the shortest path between the root node and `X` is exactly `k`. + +
+ +```python +def bfs_iterative(root): + + result = [] + queue = collections.deque([root]) + + while queue: + + node = queue.popleft() + + if node: + result.append(node.val) + queue.append(node.left) + queue.append(node.right) + + return result + +``` + +
+ +--- + +### tree traversal: depth-first search + +
+ +- dfs is used to find the path from the root node to a target node if you want to visit every node and/or search the deepest paths first. + +- recursive solutions are easier to implement, however, if the recursion depth is too high, stack overflow might occur. + - you might want to use bfs instead or implement dfs using an explicit stack (i.e., with a while loop and a stack structure). + +- dfs only traces back and try another path after it reaches the deepest node. as a result, the first path found in dfs is not always the shortest path: + - push the root node to the stack. + - try the first neighbor and push its node to the stack. + - when it reaches the deepest node, trace back by popping the deepest node from the stack (the last node pushed). therefore, he processing order of the nodes is exactly the opposite order of how they are added to the stack. + +
+ +--- + +#### in-order + +
+ +- `left -> node -> right` + +
+ +```python +def inorder_recursive(root): + + if root is None: + return [] + + return inorder_recursive(root.left) + [root.val] + inorder_recursive(root.right) + + +def inorder_iterative(root): + + node = root + result, stack = [], [] + + while stack or node: + + if node: + stack.append(node) + node = node.left + else: + node = stack.pop() + result.append(node.val) + node = node.right + + return result +``` + +
+ + +* we can also build an interator: + +
+ +```python +class inorder_iterator: + + def __init__(self, root): + self.stack = [] + self.left_inorder(root) + + def left_inorder(self, root): + while root: + self.stack.append(root) + root = root.left + + def next(self) -> int: + node = self.stack.pop() + if node.right: + self.left_inorder(node.right) + return node.val + + def has_next(self) -> bool: + return len(self.stack) > 0 +``` + +
+ + +- in a binary search tree, in-order traversal will be sorted in the ascending order. + +- converting a sorted array to a binary search tree with inorder has no unique solution (in another hand, both preorder and postorder are unique identifiers of a bst). + +
+ +--- + +#### pre-order + +
+ +- `node -> left -> right` + +
+ +```python +def preorder_recursive(root): + + if root is None: + return [] + + return [root.val] + preorder(root.left) + preorder(root.right) + + +def preorder_iterative(root) -> list: + + result = [] + stack = [root] + + while stack: + + node = stack.pop() + + if node: + result.append(node.val) + stack.append(node.right) # note the order (stacks are fifo) + stack.append(node.left) + + return result +``` + +
+ +* note that preorder dfs looks similar to bfs, but using a stack instead of queue, and calling `node.right` first than `node.left` (as it pops in the right not in the left). + +
+ +--- + +#### post-order + +
+ +- `left -> right -> node` + +- deletion process is always post-order: when you delete a node, you will delete its left child and its right child before you delete the node itself. + +- post-order can be used in mathematical expressions as it's easier to write a program to parse a post-order expression. + - using a stack, each time when you meet an operator, you can just pop 2 elements from the stack, calculate the result and push the result back into the stack. + +
+ +```python +def postorder(root): + + if root is None: + return [] + + return postorder(root.left) + postorder(root.right) + [root.val] + + +def postorder_iterative(root): + + node = root + stack, result = [], [] + + while node or stack: + + while node: + stack.append(node.right) + stack.append(node) + node = node.left + + node = stack.pop() + + if stack and node.right == stack[-1]: + stack[-1] = node + node = node.right + + else: + result.append(node.val) + node = None + + return result +``` + +
+ + +---- + +### is same tree? + +
+ +```python +def is_same_trees(p, q): + + if not p and not q: + return True + + if (not p and q) or (not q and p): + return False + + if p.val != q.val: + return False + + return is_same_trees(p.right, q.right) and is_same_trees(p.left, q.left) +```` + +
+ +--- + +### is symmetric? + +
+ +```python +def is_symmetric(root): + + stack = [(root, root)] + + while stack: + + node1, node2 = stack.pop() + + if (not node1 and node2) or (not node2 and node1): + return False + + if node1 and node2: + + if node1.val != node2.val: + return False + + stack.append([node1.left, node2.right]) + stack.append([node1.right, node2.left]) + + return True + + +def is_symmetric_recursive(root) -> bool: + + def helper(node1, node2): + if (not node1 and node2) or \ + (not node2 and node1) or \ + (node1 and node2 and node1.val != node2.val): + return False + + if (not node1 and not node2): + return True + + return helper(node1.left, node2.right) and helper(node2.left, node1.right) + + return helper(root.left, root.right) +``` + +
+ +--- + +### lowest common ancestor + +
+ +```python +def lowest_common_ancestor(root, p, q): + + stack = [root] + parent = {root: None} + + while p not in parent or q not in parent: + + node = stack.pop() + if node: + parent[node.left] = node + parent[node.right] = node + stack.append(node.left) + stack.append(node.right) + + ancestors = set() + while p: + ancestors.add(p) + p = parent[p] + + while q not in ancestors: + q = parent[q] + + return q +``` + +
+ +--- + +### has path sum? + +
+ + +```python +def has_path_sum(root, target_sum) -> bool: + + def transverse(node, sum_here=0): + + if not node: + return sum_here == target_sum + + sum_here += node.val + + if not node.left: + return transverse(node.right, sum_here) + if not node.right: + return transverse(node.left, sum_here) + else: + return transverse(node.left, sum_here) or transverse(node.right, sum_here) + + if not root: + return False + + return transverse(root) +``` + +
+ +--- + +### build tree from inorder with preorder or postorder + +
+ +* building with preorder: + +
+ +```python +def build_tree(preorder, inorder): + + def helper(left, right, index_map): + + if left > right: + return None + + node = preorder.pop(0) # this order change from postorder + root = Node(node.val) + index_here = index_map[node.val] + + root.left = helper(left, index_here - 1, index_map) # this order change from postorder + root.right = helper(index_here + 1, right, index_map) + + return root + + index_map = {value: i for i, value in enumerate(inorder)} + + return helper(0, len(inorder) - 1, index_map) +``` + +
+ +* build with postorder: + +
+ +```python +def build_tree(left, right, index_map, postorder): + + if left > right: + return None + + node = postorder.pop() # this order change from preorder + root = Node(node.val) + index_here = index_map[node.val] + + root.right = build_tree(index_here + 1, right, index_map, postorder) # this order change from preorder + root.left = build_tree(left, index_here - 1, index_map, postorder) + + return root + + +def build_tree(inorder, postorder): + + index_map = {val: i for i, value in enumerate(inorder)} + return fill_tree(0, len(inorder) - 1, index_map, postorder) +``` + + +
+ +--- + +### return number of unival subtrees + +
+ +* a unival subtree means all nodes of the subtree have the same value + +
+ +```python +def count_unival(root) -> int: + + global count = 0 + + def dfs(node): + if node is None: + return True + + if dfs(node.left) and dfs(node.right): + if (node.left and node.left.val != node.val) or \ + (node.right and node.right.val != node.val): + return False + self.count += 1 + return True + + return False + + dfs(root) + return count +``` + +
+ +--- + +### successors and precessors + +
+ +```python + +def successor(root): + + root = root.right + while root: + root = root.left + + return root + + +def predecessor(root): + + root = root.left + while root: + root = root.right + + return root +``` + +
+ + +---- + +### binary search trees + +
+ +* **binary search trees** are binary trees where all nodes on the left are smaller than the root, which is smaller than all nodes on the right. + +* if a bst is **balanced**, it guarantees `O(log(N))` for `insert` and `search` (as we keep the tree's height as `h = log(N)`). + +* common types of balanced trees are **red-black** and **avl**. + + + +
+ +--- + +### insert a node + +
+ +* to insert a node, the main strategy is to find a proper leaf position for the target (therefore, insertion will begin as a search). + +* the time complexity is `O(h)` where `h` is the tree height. that results in `O(log(N))` in the average case, and `O(N)` worst case. + +
+ +```python +def bst_insert_iterative(root, val): + + node = root + while node: + + if val > node.val: + if not node.right: + node.right = Node(val) + break + else: + node = node.right + + else: + if not node.left: + node.left = Node(val) + break + else: + node = node.left + + return root + + +def bst_insert_recursive(root, val): + + if root is None: + return Node(val) + + if val > root.val: + root.right = self.bst_insert_recursive(root.right, val) + + else: + root.left = self.bst_insert_recursive(root.left, val) + + return root +``` + +
+ + +--- + +### delete a node + +
+ +* deletion is a more complicated operation, and there are several strategies. + +* one of them is to replace the target node with a proper child: + - if the target node has no child (it's a leaf): simply remove the node + - if the target node has one child, use the child to replace the node + - if the target node has two child, replace the node with its in-order successor or predecessor node and delete the node + +* similar to the recursion solution of the search operation, the time complexity is `O(h)` in the worst case. + +* according to the depth of recursion, the space complexity is also `O(h)` in the worst case. we can also represent the complexity using the total number of nodes `N`. + +* the time complexity and space complexity will be `O(log(N))` in the best case but `O(N)` in the worse case. + + +
+ +```python + +def delete_node(root, key): + + if root is None: + return root + + if key > root.val: + root.right = delete_node(root.right, key) + + elif key < root.val: + root.left = delete_node(root.left, key) + + else: + if not (root.left or root.right): + root = None + + elif root.right: + root.val = successor(root) + root.right = delete_node(root.right, root.val) + + else: + root.val = predecessor(root) + root.left = delete_node(root.left, root.val) + + return root +``` + +
+ +--- + +### search for a value + +
+ +* for the recursive solution, the depth of the recursion is equal to the height of the tree in the worst case. therefore, the time complexity would be `O(h)`. the space complexity is also `O(h)`. + +* for the iterative solution, the time complexity is equal to the loop time which is also `O(h)`, while the space complexity is `O(1)`. + +
+ +```python +def search_bst_recursive(root, val): + + if root is None or root.val == val: + return root + if val > root.val: + return search_bst_recursive(root.right, val) + else: + return search_bst_recursive(root.left, val) + + +def search_bst_iterative(root, val): + + while root: + + if root.val == val: + break + if root.val < val: + root = root.right + else: + root = root.left + + return root +``` + + +
+ +--- + +### find successor of two nodes inorder + +
+ +```python +def find_successor(node1, node2): + + successor = None + + while node1: + + if node1.val <= node2.val: + node1 = node1.right + else: + successor = node1 + node1 = node1.left + + return successor +``` + +
+ + +--- + +### convert sorted array to bst + +
+ +* note that there is no unique solution. + +
+ +```python +def convert_sorted_array_to_bst(nums): + + def helper(left, right): + + if left > right: + return None + + p = (left + right) // 2 + + root = Node(nums[p]) + root.left = helper(left, p - 1) + root.right = helper(p + 1, right) + + return root + + return helper(0, len(nums) - 1) +``` + +
+ + +--- + +### lowest common ancestor for a bst + +
+ +```python +def lowest_common_ancestor(root, p, q): + + node, result = root, root + + while node: + + result = node + + if node.val > p.val and node.val > q.val: + node = node.left + elif node.val < p.val and node.val < q.val: + node = node.right + else: + break + + return result +``` + +
+ +--- + +### checking if bst is valid + +
+ +```python +def is_valid_bst_iterative(root): + + queue = deque((root, float(-inf), float(inf))) + + while queue: + + node, min_val, max_val = queue.popleft() + + if node: + if min_val >= node.val or node.val >= max_val: + return False + queue.append((node.left, min_val, node.val)) + queue.append((node.right, node.val, max_val)) + + return True + + +def is_valid_bst_recursive(root, min_val=float(-inf), max_val=float(inf)): + + if root is None: + return True + + return (min_val < root.val < max_val) and \ + is_valid_bst_recursive(root.left, min_val, root.val) and \ + is_valid_bst_recursive(root.right, root.val, max_val) + + +def is_valid_bst_inorder(root): + + def inorder(node): + if node is None: + return True + + inorder(node.left) + stack.append(node.val) + inorder(node.right) + + stack = [] + inorder(root) + + for i in range(1, len(stack)): + if queue[i] <= queue[i - 1]: + return False + + return True +``` + +
+ diff --git a/trees/bs_sucessor_and_precessor.py b/trees/bs_sucessor_and_precessor.py new file mode 100644 index 0000000..e7e8c45 --- /dev/null +++ b/trees/bs_sucessor_and_precessor.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def successor(root): + + root = root.right + while root: + root = root.left + + return root + + +def predecessor(root): + + root = root.left + while root: + root = root.right + + return root diff --git a/trees/bst_avl.py b/trees/bst_avl.py new file mode 100644 index 0000000..134587f --- /dev/null +++ b/trees/bst_avl.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node(): + def __init__(self, val): + self.val = val + self.left = None + self.right = None + self.height = 1 + + +class AVLTree(): + + def __init__(self): + self.root = None + self.size = 0 + + def height(self, node): + if node: + return node.height + return 0 + + def set_height(self, node): + if node is None: + return 0 + return 1 + max(self.height(node.left), self.height(node.right)) + + def right_rotate(self, node): + new_root = node.left + node.left = node.left.right + new_root.right = node + node.height = self.set_height(node) + new_root.height = self.set_height(new_root) + return new_root + + def left_rotate(self, node): + new_root = node.right + node.right = node.right.left + new_root.left = node + node.height = self.set_height(node) + new_root.height = self.set_height(new_root) + return new_root + + def insert(self, node, val): + if node == self.root: + self.size += 1 + if node is None: + return Node(val) + if node.val < val: + node.right = self.insert(node.right, val) + else: + node.left = self.insert(node.left, val) + balance = self.height(node.left) - self.height(node.right) + if balance > 1: + if self.height(node.left.left) > self.height(node.left.right): + node = self.right_rotate(node) + else: + node.left = self.left_rotate(node.left) + node = self.right_rotate(node) + elif balance < -1: + if self.height(node.right.right) > self.height(node.right.left): + node = self.left_rotate(node) + else: + node.right = self.right_rotate(node.right) + node = self.left_rotate(node) + else: + node.height = self.set_height(node) + return node + + def get_min_val(self, node): + if node is None or node.left is None: + return node + return self.get_min_val(node.left) + + def remove(self, node, val): + if node is None: + return node + if node.val < val: + node.right = self.remove(node.right, val) + elif node.val > val: + node.left = self.remove(node.left, val) + else: + if node.left is None: + return node.right + elif node.right is None: + return node.left + else: + right_min_val_node = self.get_min_val(node.right) + node.val = right_min_val_node.val + node.right = self.remove(node.right, right_min_val_node.val) + + node.height = self.set_height(node) + balance = self.height(node.left) - self.height(node.right) + if balance > 1: + if self.height(node.left.left) > self.height(node.left.right): + node = self.right_rotate(node) + else: + node.left = self.left_rotate(node.left) + node = self.right_rotate(node) + elif balance < -1: + if self.height(node.right.right) > self.height(node.right.left): + node = self.left_rotate(node) + else: + node.right = self.right_rotate(node.right) + node = self.left_rotate(node) + else: + node.height = self.set_height(node) + return node + + def predecessor(self, node, val): + if node is None: + return node + if node.val == val: + return val + elif node.val > val: + return self.predecessor(node.left, val) + else: + right_res = self.predecessor(node.right, val) + return right_res if right_res else node.val + + def successor(self, node, val): + if node is None: + return node + if node.val == val: + return val + elif node.val < val: + return self.successor(node.right, val) + else: + left_res = self.successor(node.left, val) + return left_res if left_res else node.val + + +def contains_duplicate_near(self, nums, k, t): + + avltree = AVLTree() + root = avltree.root + + + for i, num in enumerate(nums): + predecessor = avltree.predecessor(root, num) + if predecessor is not None and abs(predecessor - num) <= t: + return True + successor = avltree.successor(root, num) + if successor is not None and abs(successor - num) <= t: + return True + + root = avltree.insert(root, num) + + if avltree.size > k: + root = avltree.remove(root, nums[i-k]) + + return False + diff --git a/trees/bst_convert_sorted_array.py b/trees/bst_convert_sorted_array.py new file mode 100644 index 0000000..1d7a7db --- /dev/null +++ b/trees/bst_convert_sorted_array.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def convert_sorted_array_to_bst(nums): + + def helper(left, right): + + if left > right: + return None + + p = (left + right) // 2 + + root = Node(nums[p]) + root.left = helper(left, p - 1) + root.right = helper(p + 1, right) + + return root + + return helper(0, len(nums) - 1) + diff --git a/trees/bst_delete_node.py b/trees/bst_delete_node.py new file mode 100644 index 0000000..de122e3 --- /dev/null +++ b/trees/bst_delete_node.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def successor(root): + + root = root.right + while root.left: + root = root.left + return root.val + + +def predecessor(root): + + root = root.left + while root.right: + root = root.right + return root.val + + +def delete_node(root, key): + + if root is None: + return root + + if key > root.val: + root.right = delete_node(root.right, key) + + elif key < root.val: + root.left = delete_node(root.left, key) + + else: + if not (root.left or root.right): + root = None + + elif root.right: + root.val = successor(root) + root.right = delete_node(root.right, root.val) + + else: + root.val = predecessor(root) + root.left = delete_node(root.left, root.val) + + return root + diff --git a/trees/bst_insert_node.py b/trees/bst_insert_node.py new file mode 100644 index 0000000..65928ae --- /dev/null +++ b/trees/bst_insert_node.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def bst_insert_iterative(root, val): + + node = root + while node: + + if val > node.val: + if not node.right: + node.right = Node(val) + break + else: + node = node.right + + else: + if not node.left: + node.left = Node(val) + break + else: + node = node.left + + return root + + +def bst_insert_recursive(root, val): + + if root is None: + return Node(val) + + if val > root.val: + root.right = self.bst_insert_recursive(root.right, val) + + else: + root.left = self.bst_insert_recursive(root.left, val) + + return root diff --git a/trees/bst_is_valid.py b/trees/bst_is_valid.py new file mode 100644 index 0000000..3ff3199 --- /dev/null +++ b/trees/bst_is_valid.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def is_valid_bst_iterative(root): + + queue = deque((root, float(-inf), float(inf))) + + while queue: + + node, min_val, max_val = queue.popleft() + + if node: + if min_val >= node.val or node.val >= max_val: + return False + queue.append((node.left, min_val, node.val)) + queue.append((node.right, node.val, max_val)) + + return True + + +def is_valid_bst_recursive(root, min_val=float(-inf), max_val=float(inf)): + + if root is None: + return True + + return (min_val < root.val < max_val) and \ + is_valid_bst_recursive(root.left, min_val, root.val) and \ + is_valid_bst_recursive(root.right, root.val, max_val) + + +def is_valid_bst_inorder(root): + + def inorder(node): + if node is None: + return True + + inorder(node.left) + stack.append(node.val) + inorder(node.right) + + stack = [] + inorder(root) + + for i in range(1, len(stack)): + if queue[i] <= queue[i - 1]: + return False + + return True diff --git a/trees/bst_lowest_common_ancestor.py b/trees/bst_lowest_common_ancestor.py new file mode 100644 index 0000000..db1a945 --- /dev/null +++ b/trees/bst_lowest_common_ancestor.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def lowest_common_ancestor(root, p, q): + + node, result = root, root + + while node: + + result = node + + if node.val > p.val and node.val > q.val: + node = node.left + + elif node.val < p.val and node.val < q.val: + node = node.right + + else: + break + + return result diff --git a/trees/bst_search.py b/trees/bst_search.py new file mode 100644 index 0000000..648a82c --- /dev/null +++ b/trees/bst_search.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def search_bst_recursive(root, val): + + if root is None or root.val == val: + return root + + if val > root.val: + return search_bst_recursive(root.right, val) + + else: + return search_bst_recursive(root.left, val) + + + +def search_bst_iterative(root, val): + + while root: + + if root.val == val: + break + + if root.val < val: + root = root.right + + else: + root = root.left + + return root diff --git a/trees/bst_sucessor_two_nodes.py b/trees/bst_sucessor_two_nodes.py new file mode 100644 index 0000000..200a893 --- /dev/null +++ b/trees/bst_sucessor_two_nodes.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def find_successor(root, p): + + successor = None + + while root: + + if root.val <= p.val: + root = root.right + else: + successor = root + root = root.left + + return successor diff --git a/trees/bt.py b/trees/bt.py new file mode 100644 index 0000000..a44aec1 --- /dev/null +++ b/trees/bt.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node(object): + + def __init__(self, value): + self.value = value + self.right = None + self.left = None + + def add(self, value): + new_node = Node(value) + if not self.left: + self.left = new_node + elif not self.right: + self.right = new_node + else: + self.left = self.left.add(value) + + def search(self, item): + return self.value == item or \ + (self.left and self.left.search(item)) or \ + (self.right and self.right.search(item)) + + def preorder(self): + yield self.value + if self.left: + for node in self.left.preorder(): + yield node + if self.right: + for node in self.right.preorder(): + yield node + + def postorder(self): + yield self.value + if self.left: + for node in self.left.postorder(): + yield node + if self.right: + for node in self.right.postorder(): + yield node + + def inorder(self): + yield self.value + if self.left: + for node in self.left.inorder(): + yield node + if self.right: + for node in self.right.inorder(): + yield node + + +class BinaryTree(object): + def __init__(self): + self.root = None + + def add(self, value): + if not self.root: + self.root = Node(value) + else: + self.root.add(value) + + def search(self, item): + if self.root: + return self.root.search(item) + + def preorder(self): + if self.root: + return list(self.root.preorder()) + + def inorder(self): + if self.root: + return list(self.root.inorder()) + + def postorder(self): + if self.root: + return list(self.root.postorder()) + + +if __name__ == '__main__': + + + print("\n\n🌳🌳🌳 Testing BinaryTree 🌳🌳🌳") + bt = BinaryTree() + array1 = [4, 1, 4, 6, 7, 9, 10, 5, 11, 5] + print(f'\n🟔 Adding {array1} to the tree...') + for i in array1: + bt.add(i) + print(f"🟢 Print the tree preorder: {bt.preorder()}") + print(f"🟢 Print the tree inorder: {bt.inorder()}") + print(f"🟢 Print the tree postorder: {bt.postorder()}") + + print(f'\n🟢 Search for node 5: {bt.search(5)}') + print(f'āŒ Search for node 15: {bt.search(15)}') diff --git a/trees/bt_bfs.py b/trees/bt_bfs.py new file mode 100644 index 0000000..be713c6 --- /dev/null +++ b/trees/bt_bfs.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def bfs(root) -> list: + + result = [] + queue = collections.deque([root]) + + while queue: + + node = queue.popleft() + + if node: + result.append(node.val) + queue.append(node.left) + queue.append(node.right) + + return result diff --git a/trees/bt_construct_inorder_postorder.py b/trees/bt_construct_inorder_postorder.py new file mode 100644 index 0000000..eabd644 --- /dev/null +++ b/trees/bt_construct_inorder_postorder.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def build_tree(left, right, index_map, postorder): + + if left > right: + return None + + node = postorder.pop() # this order change from preorder + root = Node(node.val) + index_here = index_map[node.val] + + root.right = build_tree(index_here + 1, right, index_map, postorder) # this order change from preorder + root.left = build_tree(left, index_here - 1, index_map, postorder) + + return root + + +def build_tree(inorder, postorder): + + index_map = {val: i for i, value in enumerate(inorder)} + + return fill_tree(0, len(inorder) - 1, index_map, postorder) + diff --git a/trees/bt_construct_inorder_preorder.py b/trees/bt_construct_inorder_preorder.py new file mode 100644 index 0000000..9087fe5 --- /dev/null +++ b/trees/bt_construct_inorder_preorder.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def build_tree(preorder, inorder): + + def helper(left, right, index_map): + + if left > right: + return None + + node = preorder.pop(0) # this order change from postorder + root = Node(node.val) + index_here = index_map[node.val] + + root.left = helper(left, index_here - 1, index_map) # this order change from postorder + root.right = helper(index_here + 1, right, index_map) + + return root + + index_map = {value: i for i, value in enumerate(inorder)} + + return helper(0, len(inorder) - 1, index_map) + diff --git a/trees/bt_count_unival.py b/trees/bt_count_unival.py new file mode 100644 index 0000000..f68f846 --- /dev/null +++ b/trees/bt_count_unival.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + + +def count_unival(root) -> int: + + global count = 0 + + def dfs(node): + if node is None: + return True + + if dfs(node.left) and dfs(node.right): + if (node.left and node.left.val != node.val) or \ + (node.right and node.right.val != node.val): + return False + self.count += 1 + return True + + return False + + dfs(root) + return count diff --git a/trees/bt_cute.py b/trees/bt_cute.py new file mode 100644 index 0000000..b1b3826 --- /dev/null +++ b/trees/bt_cute.py @@ -0,0 +1,296 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class SimpleTree: + """Implementation of a simple tree""" + + def __init__(self, value=None, node=None): + self.value = value + self.node = node or [] + + def __repr__(self, level=0): + repr = '\t' * level + self.value + '\n' + for n in self.node: + repr += n.__repr__(level + 1) + return repr + + +class Node(): + """Implementation of a Node for a binary tree""" + + def __init__(self, value=None): + self.value = value + self.left = None + self.right = None + + ############################ + # Private Methods + ############################ + def __repr__(self): + """Prints the node""" + return f'{self.value}' + + def _repr_preorder(self): + """Prints the tree in preorder traversal (root, left, right)""" + + print(self.value) + if self.left: + self.left._repr_preorder() + if self.right: + self.right._repr_preorder() + + def _add_node_binary_tree(self, value): + """Adds a node to a simple binary tree""" + + if self.value is None: + self.value = value + + else: + if not self.left: + self.left = Node(value) + elif not self.right: + self.right = Node(value) + else: + self.left = self.left._add_node_binary_tree(value) + + return self + + def _add_node_binary_search_tree(self, value) -> bool: + """Adds a node to a binary search tree""" + + if not self.value: + self.value = value + + else: + new_node = Node(value) + if value < self.value: + self.left = self.left and self.left._add_node_binary_search_tree(value) or new_node + elif value > self.value: + self.right = self.right and self.right._add_node_binary_search_tree(value) or new_node + else: + print(f'āŒ Item {value} not added as BSTs do not support repetition.') + + return self + + def _search_node_preorder(self, query) -> bool: + """Searches through preorder traversal (node, left, right)""" + + if self.value == query: + return True + + found = False + if self.left: + # recursively search left + found = self.left._search_node_preorder(query) + + if self.right: + # recursively search right + found = found or self.right._search_node_preorder(query) + + return found + + def _search_node_binary_search_tree(self, query) -> bool: + """Searches the tree for a value, considering the BST property""" + + this_node_value = self.value + + if this_node_value is not None: + if this_node_value == query: + return True + + elif this_node_value > query: + if self.left is not None: + return self.left._search_node_binary_search_tree(query) + + elif this_node_value < query: + if self.right is not None: + return self.right._search_node_binary_search_tree(query) + + return False + + def _is_leaf(self) -> bool: + """If node has no children, it is a leaf""" + + return bool(not self.right and not self.left) + + def _is_full(self) -> bool: + """If node has two children, it is full""" + return bool(self.right and self.left) + + +class BinaryTreeInterface(): + + def __init__(self): + self.root = Node() + + ############################ + # Interface Methods + ############################ + def add_node(self, value): + """Adds a new node to the tree""" + pass + + def search_node(self, value): + """Searches the tree for a value""" + pass + + ############################ + # Public Methods + ############################ + def is_leaf(self) -> bool: + """Returns True if the node is a leaf""" + + if self.root is not None: + return self.root._is_leaf() + + def is_full(self) -> bool: + """Returns True if the node is full""" + + if self.root is not None: + return self.root._is_full() + + def print_preorder(self): + """Prints the BST in preorder""" + + if self.root is not None: + self.root._repr_preorder() + + ############################ + # Class Methods + ############################ + @classmethod + def is_balanced(cls, node, left=0, right=0) -> bool: + """Returns True if the tree is balanced""" + + if node is None: + return (left - right) < 2 + + else: + return cls.is_balanced(node.left, left + 1, right) and \ + cls.is_balanced(node.right, left, right + 1) + + @classmethod + def is_binary_search_tree(cls, node, min_node=None, max_node=None) -> bool: + """Returns True if the tree is a BST""" + + min_node = min_node or float('-inf') + max_node = max_node or float('inf') + + if not node: + return True + + if node.value < min_node or node.value > max_node: + return False + + return cls.is_binary_search_tree(node.left, min_node, node.value) and \ + cls.is_binary_search_tree(node.right, node.value, max_node) + + + +class BinaryTree(BinaryTreeInterface): + """Implementation of a binary tree""" + + def add_node(self, value): + """Adds a new node to the tree""" + + if self.root is None: + self.root = Node(value) + else: + self.root._add_node_binary_tree(value) + + def search_node(self, value): + """Searches the tree for a value""" + + if self.root: + return self.root._search_node_preorder(value) + + +class BinarySearchTree(BinaryTreeInterface): + + def add_node(self, value): + """Adds a new node to the tree""" + + if self.root is None: + self.root = Node(value) + else: + self.root._add_node_binary_search_tree(value) + + def search_node(self, value): + """Searches the tree for a value""" + + if self.root.value is not None: + return self.root._search_node_binary_search_tree(value) + + @classmethod + def largest_node(cls, node): + """Returns the largest node in the tree""" + + if node.right: + return cls.largest_node(node.right) + else: + return node + + @classmethod + def smallest_node(cls, node): + """Returns the smallest node in the tree""" + + if node.left: + return cls.smallest_node(node.left) + else: + return node + + + + +if __name__ == '__main__': + + ############################ + # Test SimpleTree + ############################ + print("\n\n🌓🌓🌓 Testing SimpleTree 🌓🌓🌓") + t = SimpleTree('a', [SimpleTree('b', [SimpleTree('d'), SimpleTree('e')]), \ + SimpleTree('c', [SimpleTree('h'), SimpleTree('g')])]) + print(t) + + + ############################ + # Test binary tree + ############################ + print("\n\n🌳🌳🌳 Testing BinaryTree 🌳🌳🌳") + bt = BinaryTree() + array1 = [4, 1, 4, 6, 7, 9, 10, 5, 11, 5] + print(f'\n🟔 Adding {array1} to the tree...') + for i in array1: + bt.add_node(i) + print("🟢 Printing the tree in preorder...") + bt.print_preorder() + print(f'\n🟢 Searching for node 5: {bt.search_node(5)}') + print(f'āŒ Searching for node 15: {bt.search_node(15)}') + print(f'āŒ Is root a leaf? {bt.is_leaf()}') + print(f'🟢 Is root full? {bt.is_full()}') + print(f'āŒ Is the tree balanced? {BinaryTree.is_balanced(bt.root)}') + print(f'āŒ Is the tree a binary search tree? {BinaryTree.is_binary_search_tree(bt.root)}') + + + + ############################## + # Test binary search tree + ############################## + print("\n\nšŸŽ„šŸŽ„šŸŽ„ Testing BinarySearchTree šŸŽ„šŸŽ„šŸŽ„") + bst = BinarySearchTree() + array1 = [4, 1, 4, 6, 7, 9, 10, 5, 11, 5] + print(f'\n🟔 Adding {array1} to the tree...') + for i in array1: + bst.add_node(i) + print("🟢 Printing the tree in preorder:") + bst.print_preorder() + print(f'\n🟢 Searching for node 5: {bst.search_node(5)}') + print(f'āŒ Searching for node 15: {bst.search_node(15)}') + print(f'āŒ Is root a leaf? {bst.is_leaf()}') + print(f'🟢 Is root full? {bst.is_full()}') + print(f'🟢 Largest node? {bst.largest_node(bst.root)}') + print(f'🟢 Smallest node? {bst.smallest_node(bst.root)}') + print(f'āŒ Is the tree balanced? {bst.is_balanced(bst.root)}') + print(f'🟢 Is the tree a binary search tree? {bst.is_binary_search_tree(bst.root)}') diff --git a/trees/bt_find_max_depth.py b/trees/bt_find_max_depth.py new file mode 100644 index 0000000..dbe2109 --- /dev/null +++ b/trees/bt_find_max_depth.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def max_depth(root) -> int: + + if root is None: + return 0 + + return max(max_depth(root.left) + 1, max_depth(root.right) + 1) + diff --git a/trees/bt_has_path_sum.py b/trees/bt_has_path_sum.py new file mode 100644 index 0000000..b58d8af --- /dev/null +++ b/trees/bt_has_path_sum.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def has_path_sum(root, target_sum) -> bool: + + def transverse(node, sum_here=0): + + if not node: + return sum_here == target_sum + + sum_here += node.val + + if not node.left: + return transverse(node.right, sum_here) + if not node.right: + return transverse(node.left, sum_here) + else: + return transverse(node.left, sum_here) or transverse(node.right, sum_here) + + if not root: + return False + + return transverse(root) + diff --git a/trees/bt_height.py b/trees/bt_height.py new file mode 100644 index 0000000..b10b178 --- /dev/null +++ b/trees/bt_height.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def height(root): + + if root is None: + return 0 + + return 1 + max(height(root.left), height(root.right)) + diff --git a/trees/bt_inorder.py b/trees/bt_inorder.py new file mode 100644 index 0000000..6a955cf --- /dev/null +++ b/trees/bt_inorder.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def inorder(root) -> list: + + if root is None: + return [] + + return inorder(root.left) + [root.val] + inorder(root.right) + + +def inorder_iterative(root) -> list: + + result = [] + stack = [] + node = root + + while stack or node: + + if node: + stack.append(node) + node = node.left + else: + node = stack.pop() + result.append(node.val) + node = node.right + + return result + diff --git a/trees/bt_inorder_iterator.py b/trees/bt_inorder_iterator.py new file mode 100644 index 0000000..3006da9 --- /dev/null +++ b/trees/bt_inorder_iterator.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Node: + def __init__(self, left=None, right=None): + self.val = val + self.left = left + self.right = right + + +class InorderIterator: + + def __init__(self, root): + self.stack = [] + self.left_inorder(root) + + def left_inorder(self, root): + while root: + self.stack.append(root) + root = root.left + + def next(self) -> int: + top_node = self.stack.pop() + if top_node.right: + self.left_inorder(top_node.right) + return top_node.val + + def has_next(self) -> bool: + return len(self.stack) > 0 + diff --git a/trees/bt_is_balanced.py b/trees/bt_is_balanced.py new file mode 100644 index 0000000..1d3772b --- /dev/null +++ b/trees/bt_is_balanced.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def height(root): + + if root is None: + return -1 + + return 1 + max(height(root.left), height(root.right)) + + +def is_balanced(root): + + if root is None: + return True + + return abs(height(root.left) - height(root.right)) < 2 and \ + is_balanced(root.left) and is_balanced(root.right) + diff --git a/trees/bt_is_same_trees.py b/trees/bt_is_same_trees.py new file mode 100644 index 0000000..8cd7a28 --- /dev/null +++ b/trees/bt_is_same_trees.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def is_same_trees(p, q): + + if not p and not q: + return True + + if (not p and q) or (not q and p) or p.val != q.val: + return False + + return is_same_trees(p.right, q.right) and is_same_trees(p.left, q.left) diff --git a/trees/bt_is_tree_symmetric.py b/trees/bt_is_tree_symmetric.py new file mode 100644 index 0000000..27f3faa --- /dev/null +++ b/trees/bt_is_tree_symmetric.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def is_symmetric(root) -> bool: + + stack = [(root, root)] + + while stack: + + node1, node2 = stack.pop() + + if (not node1 and node2) or (not node2 and node1): + return False + + elif node1 and node2 and node1.val != node2.val: + return False + + elif not node1 and not node2: + continue + + stack.append([node1.left, node2.right]) + stack.append([node1.right, node2.left]) + + return True + + +def is_symmetric_recursive(root) -> bool: + + def helper(node1, node2): + if (not node1 and node2) or \ + (not node2 and node1) or \ + (node1 and node2 and node1.val != node2.val): + return False + + if (not node1 and not node2): + return True + + return helper(node1.left, node2.right) and helper(node2.left, node1.right) + + return helper(root.left, root.right) + diff --git a/trees/bt_lowest_common_ancestor.py b/trees/bt_lowest_common_ancestor.py new file mode 100644 index 0000000..429b41e --- /dev/null +++ b/trees/bt_lowest_common_ancestor.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def lowest_common_ancestor(root, p, q): + + stack = [root] + parent = {root: None} + + while p not in parent or q not in parent: + + node = stack.pop() + if node: + parent[node.left] = node + parent[node.right] = node + stack.append(node.left) + stack.append(node.right) + + ancestors = set() + while p: + ancestors.add(p) + p = parent[p] + + while q not in ancestors: + q = parent[q] + + return q + diff --git a/trees/bt_postorder.py b/trees/bt_postorder.py new file mode 100644 index 0000000..d3aa1a1 --- /dev/null +++ b/trees/bt_postorder.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def postorder(root) -> list: + + if root is None: + return [] + + return postorder(root.left) + postorder(root.right) + [root.val] + + +def postorder_iterative(root) -> list: + + stack, result = [], [] + node = root + + while node or stack: + + while node: + if node.right: + stack.append(node.right) + stack.append(node) + node = node.left + + node = stack.pop() + + if stack and node.right == stack[-1]: + stack[-1] = node + node = node.right + + else: + result.append(node.val) + node = None + + return result + diff --git a/trees/bt_preorder.py b/trees/bt_preorder.py new file mode 100644 index 0000000..352cc05 --- /dev/null +++ b/trees/bt_preorder.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +def preorder(root) -> list: + + if root is None: + return [] + + return [root.val] + preorder(root.left) + preorder(root.right) + + +def preorder_iterative(root) -> list: + + result = [] + stack = [root] + + while stack: + + node = stack.pop() + + if node: + result.append(node.val) + stack.append(node.right) # not the order + stack.append(node.left) + + return result diff --git a/tries/README.md b/tries/README.md new file mode 100644 index 0000000..81e478c --- /dev/null +++ b/tries/README.md @@ -0,0 +1,202 @@ +## tries + +
+ +* tries, also called prefix tree, are a variant of n-ary tree in which characters are stored in each node. they are used to make searching and storing more efficient, as search, insert, and remove are `O(m)` (`m` being the length of the string). + +* tries structures can be represented by arrays and maps or trees. + * comparying with a hash table, they lose in terms of time complexity, as hash table insert is usually `O(1)` (worst case `O(log(N))`, and trie's are `O(m)` (where `m` is the maximum length of a key). + * however, trie wins in terms of space complexity. both `O(m * N)` in theory, but tries can be much smaller as there will be a lot of words that have similar prefix. + + + +* each trie node represents a string (a prefix) and each path down the tree represents a word. note that not all the strings represented by trie nodes are meaningful. the root is associated with the empty string. + * the `*` nodes (`None` nodes) are often used to indicate complete words (usually represented by a special type of child) or a boolean flag that terminates the parent node. + * a node can have anywhere from 1 through `alphabet_size + 1` child. + +* tries can be used to store the entire english language for quick prefix lookup. they are also widely used on autocompletes, spell checkers, and ip routing (longest prefix matching). + + + +
+ +```python +class Trie: + + def __init__(self): + self.root = {} + + def insert(self, word: str)L + node = self.root + for c in word: + if c not in node: + node[c] = {} + node = node[c] + node['$'] = None + + def match(self, seq, prefix=False): + node = self.root + for c in seq: + if c not in node: + return False + node = node[c] + return prefix or ('$' in node) + + def search(self, word: str) -> bool: + return self.match(word) + + def starts_with(self, prefix: str) -> bool: + return self.match(prefix, True) +``` + +
+ +---- + +### insertion + +
+ +* similar to a bst, when we insert a value to a trie, we need to decide which path to go depending on the target value we insert. + + +* the root node needs to be initialized before you insert strings. + +
+ + +--- + +### search + +
+ +* all the descendants of a node have a common prefix of the string associated with that node, so it should be easy to search if there are any words in the trie that starts with the given prefix. + + +* we go down the tree depending on the given prefix, once we cannot find the child node, the search fails. + + +* we can also search for a specific word rather than a prefix, treating this word as a prefix and searching in the same way as above. + + +* if the search succeeds, we need to check if the target word is only a prefix of words in the trie or if it's exactly a word (for example, by adding a boolean flag). + +
+ +#### bfs + +
+ +```python +def level_orders(root): + + if root is None: + return [] + + result = [] + queue = collections.deque([root]) + + while queue: + level = [] + + for _ in range(len(queue)): + node = queue.popleft() + level.append(node.val) + queue.extend(node.children) + result.append(level) + + return result +``` + +
+ +#### post order + +
+ +```python +def postorder(self, root: 'Node'): + + if root is None: + return [] + + stack, result = [root, ], [] + + while stack: + + node = stack.pop() + + if node is not None: + result.append(node.val) + + for c in node.children: + stack.append(c) + + return result[::-1] +``` + +
+ +#### pre-order + +
+ +```python +def preorder(root: 'Node'): + + if root is None: + return [] + + stack, result = [root, ], [] + + while stack: + + node = stack.pop() + result.append(node.val) + stack.extend(node.children[::-1]) + + return result +``` + +
+ +---- + +### max depth + +
+ +```python +def max_depth_recursive(root): + + if root is None: + return 0 + + if root.children: is None: + return 1 + + height = [max_depth_recursive(children) for children in root.children] + + return max(height) + 1 + + +def max_depth_iterative(root): + + stack, depth = [], 0 + + if root is not None: + stack.append((1, root)) + + while stack: + + this_depth, node = stack.pop() + + if node is not None: + + depth = max(depth, this_depth) + for c in node.children: + stack.append((this_depth + 1, c)) + + return depth +``` diff --git a/tries/trie.py b/tries/trie.py new file mode 100644 index 0000000..c5dd85f --- /dev/null +++ b/tries/trie.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + +class Trie: + + def __init__(self): + self.root = {} + + def insert(self, word: str) -> None: + node = self.root + for c in word: + if c not in node: + node[c] = {} + node = node[c] + node['$'] = None + + def match(self, seq, prefix=False) -> bool: + node = self.root + for c in seq: + if c not in node: + return False + node = node[c] + return prefix or ('$' in node) + + def search(self, word: str) -> bool: + return self.match(word) + + def starts_with(self, prefix: str) -> bool: + return self.match(prefix, True) diff --git a/tries/trie_bfs.py b/tries/trie_bfs.py new file mode 100644 index 0000000..378b0c9 --- /dev/null +++ b/tries/trie_bfs.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + def __init__(self, val=None, children=None): + self.val = val + self.children = children + + +def level_orders(root): + + if root is None: + return [] + + result = [] + queue = collections.deque([root]) + + while queue: + level = [] + + for _ in range(len(queue)): + node = queue.popleft() + level.append(node.val) + queue.extend(node.children) + result.append(level) + + return result diff --git a/tries/trie_find_height.py b/tries/trie_find_height.py new file mode 100644 index 0000000..618ff8a --- /dev/null +++ b/tries/trie_find_height.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +class Node: + + def __init__(self, val=None, children=None): + self.val = val + self.children = children + + +def max_depth_recursive(root): + + if root is None: + return 0 + + if root.children: is None: + return 1 + + height = [max_depth_recursive(children) for children in root.children] + + return max(height) + 1 + + +def max_depth_iterative(root): + + stack, depth = [], 0 + + if root is not None: + stack.append((1, root)) + + while stack: + + this_depth, node = stack.pop() + + if node is not None: + + depth = max(depth, this_depth) + for c in node.children: + stack.append((this_depth + 1, c)) + + return depth diff --git a/tries/trie_postorder.py b/tries/trie_postorder.py new file mode 100644 index 0000000..07aa755 --- /dev/null +++ b/tries/trie_postorder.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def postorder(self, root: 'Node'): + + if root is None: + return [] + + stack, result = [root, ], [] + + while stack: + + node = stack.pop() + + if node is not None: + result.append(node.val) + + for c in node.children: + stack.append(c) + + return result[::-1] + diff --git a/tries/trie_preorder.py b/tries/trie_preorder.py new file mode 100644 index 0000000..6f2044e --- /dev/null +++ b/tries/trie_preorder.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + + +def preorder(root: 'Node'): + + if root is None: + return [] + + stack, result = [root, ], [] + + while stack: + + node = stack.pop() + result.append(node.val) + stack.extend(node.children[::-1]) + + return result