From 530a8854a9c9281182ac2efc3178caaf42e85c4d Mon Sep 17 00:00:00 2001 From: Kuf <250875@student.pwr.edu.pl> Date: Tue, 9 Jun 2020 21:07:27 -0500 Subject: [PATCH] Bitcoin is our future <3 --- .DS_Store | Bin 0 -> 6148 bytes LICENSE | 21 --- README.md | 2 - l1 | 6 - l2 | 2 - l3 | 10 -- l4 | 21 --- l5.py | 143 ++++++++++++++++++ searching_methods/src/algorithms/bubble.java | 28 ---- searching_methods/src/algorithms/insert.java | 37 ----- searching_methods/src/algorithms/quick.java | 44 ------ searching_methods/src/algorithms/select.java | 38 ----- .../src/algorithms/sorting_algorithm.java | 38 ----- searching_methods/src/testing/main.java | 56 ------- 14 files changed, 143 insertions(+), 303 deletions(-) create mode 100644 .DS_Store delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 l1 delete mode 100644 l2 delete mode 100644 l3 delete mode 100644 l4 create mode 100644 l5.py delete mode 100644 searching_methods/src/algorithms/bubble.java delete mode 100644 searching_methods/src/algorithms/insert.java delete mode 100644 searching_methods/src/algorithms/quick.java delete mode 100644 searching_methods/src/algorithms/select.java delete mode 100644 searching_methods/src/algorithms/sorting_algorithm.java delete mode 100644 searching_methods/src/testing/main.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..eaef94e3040bea155873cbc94c1292a1243d2588 GIT binary patch literal 6148 zcmeHK&2AGh5FV!qb%GE%RBDfV0Et6{Ql&qqid9+;y&)~4hl1K&616KW>nPa}wP~t- z4R`^bg(u)~!Z)@XHMCr5g=VDjHy+Q}@#o0iAtKcs_cn=|M5LjNl{%VxgvVL$NX2_< zK*e($X6AE}nFM{FP~`D5z-L#b*K|fH6@Q%H4~)H-Td^Bi#3hr_z@PKaWRRt!qTT+b zDl666lU1!7y78>>DLOZksECX4s2dNDx%VzE&J%CHHzr%yaq=PUPfnU^`z9~qH17{> za@y-7LrXoz8YE=vrzb>T6ymA2EM~sZ18I|%rldp!N>76%4iED4d`N-BDIduSGOqQ z$nEo)oQfBX0Pe>q8d!hkUFUooJn2hl+nTk>z~oz3xE8$eH?EF4!l lT%^FTPcdToDc*oufj?ja7 0: + #print(str(bids)) + next_offer = bids.pop(0) + print("Next offer: " + str(next_offer)) + next_ammount = min(currency_to_sell, float(next_offer[1])) + currency_to_sell -= next_ammount + sum_ammount += next_ammount * float(next_offer[0]) + return sum_ammount + +#Dodatek + #Sprawdzanie automatyczne co 2 sekundy wartosci portfela +def to_base_currency_loop(wallet, market, base_currency): + time.sleep(2) + answer = to_base_currency(wallet,market, base_currency) + print("Total: " + str(answer)) + +def main(): + wallet = input_wallet() + base_currency = input_base_currency() + answer = to_base_currency(wallet, market_names[0], base_currency) + print("Total of " + base_currency + " after calculation = " + str(answer)) + +main() +#to_base_currency diff --git a/searching_methods/src/algorithms/bubble.java b/searching_methods/src/algorithms/bubble.java deleted file mode 100644 index bd80ecee..00000000 --- a/searching_methods/src/algorithms/bubble.java +++ /dev/null @@ -1,28 +0,0 @@ -package algorithms; - -import java.util.ArrayList; - -public class bubble extends sorting_algorithm -{ - public bubble() - { - super(); - } - - public bubble(ArrayList source) - { - super(source); - } - - @Override - public ArrayList sort_out() - { - int size = to_be_sorted.size(); - for(int i = 0; i < size; i++) - for(int j = 0; j < size - 1; j++) - if(to_be_sorted.get(j) > to_be_sorted.get(j + 1)) - swap(j, j + 1); - - return to_be_sorted; - } -} diff --git a/searching_methods/src/algorithms/insert.java b/searching_methods/src/algorithms/insert.java deleted file mode 100644 index 4e81792c..00000000 --- a/searching_methods/src/algorithms/insert.java +++ /dev/null @@ -1,37 +0,0 @@ -package algorithms; - -import java.util.ArrayList; - -public class insert extends sorting_algorithm -{ - public insert() - { - super(); - } - - public insert(ArrayList to_be_sorted) - { - super(to_be_sorted); - } - - @Override - public ArrayList sort_out() - { - int size = to_be_sorted.size(); - for (int i = 1; i < size; i++) - { - int key = to_be_sorted.get(i); - int j = i - 1; - - while (j >= 0 && to_be_sorted.get(j) > key) - { - to_be_sorted.set(j + 1, to_be_sorted.get(j)); - j = j - 1; - } - - to_be_sorted.set(j + 1, key); - } - - return to_be_sorted; - } -} diff --git a/searching_methods/src/algorithms/quick.java b/searching_methods/src/algorithms/quick.java deleted file mode 100644 index b1b7ea75..00000000 --- a/searching_methods/src/algorithms/quick.java +++ /dev/null @@ -1,44 +0,0 @@ -package algorithms; - -import java.util.ArrayList; - -public class quick extends sorting_algorithm -{ - public quick() - { - super(); - } - - public quick(ArrayList source) - { - super(source); - } - - @Override - public ArrayList sort_out() - { - sorting_procedure(0, to_be_sorted.size() - 1); - - return to_be_sorted; - } - - void sorting_procedure(int low, int high) - { - int pivot = to_be_sorted.get((low + high) / 2); - int i = low, j = high; - - do{ - while (to_be_sorted.get(i) < pivot) i++; - while (to_be_sorted.get(j) > pivot) j--; - if (i <= j) - { - swap(i, j); - i++; - j--; - } - } while (i <= j); - - if (j > low) sorting_procedure(low, j); - if (i < high) sorting_procedure(i, high); - } -} diff --git a/searching_methods/src/algorithms/select.java b/searching_methods/src/algorithms/select.java deleted file mode 100644 index 2b5ac8f9..00000000 --- a/searching_methods/src/algorithms/select.java +++ /dev/null @@ -1,38 +0,0 @@ -package algorithms; - -import java.util.ArrayList; - -public class select extends sorting_algorithm -{ - public select() - { - super(); - } - - public select(ArrayList source) - { - super(source); - } - - @Override - public ArrayList sort_out() - { - for (int i = to_be_sorted.size(); i >= 2; i--) - { - int max = max_element_index(i); - if (max != i - 1) - swap(i - 1, max); - } - - return to_be_sorted; - } - - int max_element_index(int limit) - { - int max = 0; - for (int i = 1; i < limit; i++) - if (to_be_sorted.get(i) > to_be_sorted.get(max)) - max = i; - return max; - } -} diff --git a/searching_methods/src/algorithms/sorting_algorithm.java b/searching_methods/src/algorithms/sorting_algorithm.java deleted file mode 100644 index 34f95675..00000000 --- a/searching_methods/src/algorithms/sorting_algorithm.java +++ /dev/null @@ -1,38 +0,0 @@ -package algorithms; - -import java.util.ArrayList; - -public abstract class sorting_algorithm -{ - ArrayList to_be_sorted; - - sorting_algorithm() - { - this.to_be_sorted = new ArrayList<>(); - } - - sorting_algorithm(ArrayList to_be_sorted) - { - this.to_be_sorted = new ArrayList<>(to_be_sorted.size()); - this.to_be_sorted.addAll(to_be_sorted); - } - public void change_source(ArrayList to_be_sorted) - { - this.to_be_sorted = new ArrayList<>(to_be_sorted.size()); - this.to_be_sorted.addAll(to_be_sorted); - } - - void swap(int index_1, int index_2) - { - int temp = to_be_sorted.get(index_1); - to_be_sorted.set(index_1, to_be_sorted.get(index_2)); - to_be_sorted.set(index_2, temp); - } - public ArrayList sort_out(ArrayList to_be_sorted) - { - change_source(to_be_sorted); - return sort_out(); - } - - abstract public ArrayList sort_out(); -} diff --git a/searching_methods/src/testing/main.java b/searching_methods/src/testing/main.java deleted file mode 100644 index 14206c2f..00000000 --- a/searching_methods/src/testing/main.java +++ /dev/null @@ -1,56 +0,0 @@ -package testing; - -import algorithms.*; - -import java.util.ArrayList; -import java.util.Random; - -public class main -{ - static Random seed = new Random(); - static ArrayList randomize_new_array(int size) - { - ArrayList new_array = new ArrayList(size); - for (int i = 0; i < size; i++) new_array.add(seed.nextInt()); - return new_array; - } - - static void print_array_out(ArrayList array) - { - for (Integer integer : array) - System.out.println(integer); - - System.out.println("🧶-----------------------🐈"); - } - - static float estimate_sorting_duration(sorting_algorithm algorithm, ArrayList> arrays) - { - if(arrays.isEmpty()) return -1; - - long start_time = System.currentTimeMillis(); - - for (ArrayList array : arrays) - algorithm.sort_out(array); - - return (float)(System.currentTimeMillis() - start_time) / arrays.size(); - } - - public static void main(String args[]) - { - int number_of_tests = 10, test_size = 10000; - ArrayList> set_of_tests = new ArrayList>(number_of_tests); - - for (int i = 0; i < number_of_tests; i++) - set_of_tests.add(randomize_new_array(test_size)); - - bubble bubble_sort = new bubble(); - insert insert_sort = new insert(); - select select_sort = new select(); - quick quick_sort = new quick(); - - System.out.println(estimate_sorting_duration(bubble_sort, set_of_tests) + " [ms]"); - System.out.println(estimate_sorting_duration(insert_sort, set_of_tests) + " [ms]"); - System.out.println(estimate_sorting_duration(select_sort, set_of_tests) + " [ms]"); - System.out.println(estimate_sorting_duration(quick_sort, set_of_tests) + " [ms]"); - } -}