Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.util.Arrays; | |
public class App { | |
public static void main(String[] args) throws Exception { | |
// calculating how many times a number is repeated in an array | |
int[] arr = new int[50]; | |
for (int i = 0; i < arr.length; i++) { | |
arr[i] = (int) (Math.random() * 10) + 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
from collections import Counter | |
class Fraction(object): | |
""" | |
A number represented as a fraction | |
""" | |
def __init__(self, num, denom): | |
assert type(num) == int and type(denom) == int, "ints not used" | |
self.num = num | |
self.denom = denom | |
def __str__(self): |
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 Towers(n, fr, to, spare): | |
if n > 0: | |
Towers(n-1, fr, spare, to) | |
# When you add an f you can print variables using | |
# {} instead of using the print function directly | |
# without the need of concatenation. | |
print(f'move disk from {fr} to {to}') | |
Towers(n-1, spare, to, fr) | |
Towers(31, "A", "C", "B") # A, B, C are the towers |