This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # A BELL, ah! so sweet its chime | |
| # An outlandish woman lost in time | |
| # Both are key to this fantasy rhyme | |
| # and combined could be useful in crime | |
| # | |
| # ETPPVVJAEHHLCF | |
| import string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| # The original script was not originally written by me. I found it at rcjhawk's | |
| # blog: | |
| # | |
| # http://hawknotes.blogspot.com/2010/06/finding-your-external-ip-address.html | |
| # | |
| # I had to do a minute of tweaking to get it running on OS X. Specifically, the | |
| # route command on OS X doesn't print out the routing tables as it does on | |
| # Ubuntu - the netstat command is used instead. The -n option for the echo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From Operation Code slack | |
| # *=== Monday Oct 1st 2018 - Daily Programmer ===* | |
| # | |
| # *[Number Sort]* | |
| # | |
| # Given an integer, soft the digits in ascending order and return the new integer. Ignore leading zeros. | |
| # | |
| # Constraints: Do not convert the integer into a string or other data type. | |
| # Time: O(N) | |
| # Space: O(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reverse_number(number) | |
| digit_counts = Hash.new(0) | |
| while number > 0 | |
| digit_counts[number % 10] += 1 | |
| number /= 10 | |
| end | |
| (1..9).inject(0) do |accum, digit| | |
| (0...digit_counts[digit]).inject(accum) do |accum2, _| | |
| accum2 * 10 + digit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This problem has the properties of having optimal substructure | |
| # and overlapping sub problems. Meaning, if we have the optimal | |
| # solution for smaller parts of the problem, we can compute | |
| # the optimal solution for the containing problem. | |
| # | |
| # We compute the path count using a dynamic programming algorithm. | |
| # | |
| # We recognize that the number of ways to get to each position | |
| # is the sum of the number of ways to get to the position to | |
| # the left of the current position and the number of ways to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This solution computes a memoization of solutions that reduces the exponential | |
| # explosion of the depth-first recursive algorithm. | |
| defmodule AllPaths do | |
| # Computes a map with the answers and returns the answer at {width, height} | |
| def all_paths(width, height) do | |
| all_paths_helper(%{}, {width, height}) | |
| |> Map.get({width, height}) | |
| end | |
| # Base case: at the left column |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From Operation Code slack #daily-programmer | |
| # | |
| # *=== Wednesday Oct 10th 2018 - Daily Programmer ===* | |
| # | |
| # *[Word Count Engine]* | |
| # | |
| # Implement a document scanning function `wordCountEngine`, which receives a | |
| # string document and returns a list of all unique words in it and their number | |
| # of occurrences, sorted by the number of occurrences in a descending order. If | |
| # two or more words have the same count, they should be sorted according to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # *[Bracket Match - O(1) Space]* | |
| # | |
| # A string of brackets is considered correctly matched if every opening bracket | |
| # in the string can be paired up with a later closing bracket, and vice | |
| # versa. For instance, “(())()” is correctly matched, whereas “)(“ and “((” | |
| # aren’t. For instance, “((” could become correctly matched by adding two | |
| # closing brackets at the end, so you’d return 2. | |
| # | |
| # Given a string that consists of brackets, write a function bracketMatch that | |
| # takes a bracket string as an input and returns the minimum number of brackets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # *[Make Change]* | |
| # | |
| # Write a function that returns a list that contains the minimum list of coins that can meet to the provided value. | |
| # | |
| # ```>> makeChange(39) | |
| # => [25, 10, 1, 1, 1, 1] | |
| # ^ if no coins are passed in, it defaults to [25, 10, 5, 1] | |
| # | |
| # >> makeChange(14, [10, 7, 1]) | |
| # => [7, 7]``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # *=== Wednesday Oct 24th 2018 - Daily Programmer ===* | |
| # *[Find a Missing Number]* | |
| # You are given a list of positive integers from 1 to n. There are no duplicates in list. | |
| # *One* of the integers is missing in the list. | |
| # Write a function to find the two missing integers. | |
| # Examples: | |
| # ```listA = [1, 2, 4, 5] // 3 |
OlderNewer