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
| import json; | |
| def get_bills(amount): | |
| leftover = amount | |
| # for $100 bills | |
| bills_100 = int( ( leftover - (leftover % 100) ) / 100 ) | |
| leftover = leftover % 100 | |
| # for $50 bills | |
| bills_50 = int( ( leftover - (leftover % 50) ) / 50 ) | |
| leftover = leftover % 50 |
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
| function getBills(amount){ | |
| let leftover = amount; | |
| // for $100 bills | |
| let bills_100 = ( leftover - (leftover % 100) ) / 100; | |
| leftover = leftover % 100; | |
| // for $50 bills | |
| let bills_50 = ( leftover - (leftover % 50) ) / 50; | |
| leftover = leftover % 50; | |
| // for $20 bills | |
| let bills_20 = ( leftover - (leftover % 20) ) / 20; |
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
| #include <fstream> | |
| #include <iostream> | |
| using namespace std; | |
| int main(){ | |
| ifstream file("file.txt", ifstream::in); | |
| char token; | |
| while (file >> token){ | |
| cout << token << endl; | |
| } |
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
| import java.lang.Math; | |
| public class HelloWorld | |
| { | |
| public static void main(String[] args) | |
| { | |
| int output = binaryToInt("11010"); | |
| System.out.println(output); | |
| } |
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 binary_to_int(digits): | |
| last = len(digits) - 1 | |
| sum = 0 | |
| for i in range(0, len(digits)): | |
| digit = int(digits[i]) | |
| exponent = last - i | |
| multiplier = 2 ** exponent | |
| integer = digit * multiplier | |
| sum += integer | |
| return sum |
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
| function binaryToDecimal(digits){ | |
| const last = digits.length - 1; | |
| let sum = 0; | |
| for(let i=0; i<digits.length; i++){ | |
| let digit = parseInt(digits[i]); | |
| let exponent = last - i; | |
| let multiplier = 2 ** exponent; | |
| let decimal = digit * multiplier; | |
| sum += decimal; | |
| } |
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 binary_to_int(digits) | |
| last = digits.size - 1 | |
| sum = 0 | |
| (0..(digits.size-1)).each do |i| | |
| digit = digits[i].to_i | |
| exponent = last - i | |
| multiplier = 2 ** exponent | |
| integer = digit * multiplier | |
| sum += integer | |
| end |
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
| require 'minitest/autorun' | |
| class Foo | |
| def initialize(id, bar) | |
| @id = id | |
| @bar = bar | |
| end | |
| def update | |
| @bar.log |
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
| <html> | |
| <head> | |
| <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | |
| <script src="https://unpkg.com/@popperjs/core@2"></script> | |
| <script src="https://unpkg.com/tippy.js@6"></script> | |
| <style> | |
| .grid .box { | |
| width:12px; |
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
| function quicksort(data, first, last){ | |
| if(first < last){ | |
| mid = partition(data, first, last) | |
| quicksort(data, first, mid-1) | |
| quicksort(data, mid+1, last) | |
| } | |
| } | |
| function partition(data, first, last){ | |
| pivot = data[first] |
NewerOlder