From ae6396c37783ee571cc5a54f1202004112f6117b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Palmborg?= Date: Tue, 6 Apr 2021 13:28:21 +0200 Subject: [PATCH] Consistent dir names --- README.md | 2 +- pseudoprime-numbers/main.cpp | 36 ++++++++++++------ .../p100.c | 0 .../Makefile | 0 .../main.cpp | 0 .../Makefile | 0 .../main.cpp | 0 .../tests | 0 .../Makefile | 0 .../main.cpp | 0 {u10684-The-Jackpot => u10684-the-jackpot}/t1 | 0 {u10684-The-Jackpot => u10684-the-jackpot}/t2 | 0 {u10684-The-Jackpot => u10684-the-jackpot}/t3 | 0 {u10684-The-Jackpot => u10684-the-jackpot}/t4 | 0 .../Makefile | 0 .../main.cpp | 0 .../Makefile | 0 .../main.cpp | 0 .../test | 0 .../Makefile | 0 .../main.cpp | 0 .../t1 | 0 .../tests | 0 .../p116.c | 0 {u1262-Password => u1262-password}/Makefile | 0 {u1262-Password => u1262-password}/main.cpp | 0 {u1262-Password => u1262-password}/t1 | 0 {u1262-Password => u1262-password}/t2 | 0 {u1262-Password => u1262-password}/t21 | 0 {u1262-Password => u1262-password}/t3 | 0 {u1262-Password => u1262-password}/t4 | 0 {u1262-Password => u1262-password}/t5 | 0 .../231.py | 0 {u441-Lotto => u441-lotto}/solve.py | 0 {u441-Lotto => u441-lotto}/t1 | 0 {u441-Lotto => u441-lotto}/t2 | 0 {u441-Lotto => u441-lotto}/tests | 0 .../Makefile | 0 .../main.cpp | 0 .../out | 0 .../t1 | 0 .../t2 | 0 .../tst | Bin .../642.py | 0 .../Makefile | 0 .../main.cpp | 0 .../t0 | 0 .../test | 0 48 files changed, 25 insertions(+), 13 deletions(-) rename {u100-The-3n+1-Problem => u100-the-3n+1-problem}/p100.c (100%) rename {u10071-Back-to-High-School-Physics => u10071-back-to-high-school-physics}/Makefile (100%) rename {u10071-Back-to-High-School-Physics => u10071-back-to-high-school-physics}/main.cpp (100%) rename {u10168-Summation-of-Four-Primes => u10168-summation-of-four-primes}/Makefile (100%) rename {u10168-Summation-of-Four-Primes => u10168-summation-of-four-primes}/main.cpp (100%) rename {u10168-Summation-of-Four-Primes => u10168-summation-of-four-primes}/tests (100%) rename {u10684-The-Jackpot => u10684-the-jackpot}/Makefile (100%) rename {u10684-The-Jackpot => u10684-the-jackpot}/main.cpp (100%) rename {u10684-The-Jackpot => u10684-the-jackpot}/t1 (100%) rename {u10684-The-Jackpot => u10684-the-jackpot}/t2 (100%) rename {u10684-The-Jackpot => u10684-the-jackpot}/t3 (100%) rename {u10684-The-Jackpot => u10684-the-jackpot}/t4 (100%) rename {u10812-Beat-the-Spread => u10812-beat-the-spread}/Makefile (100%) rename {u10812-Beat-the-Spread => u10812-beat-the-spread}/main.cpp (100%) rename {u11264-Coin-Collector => u11264-coin-collector}/Makefile (100%) rename {u11264-Coin-Collector => u11264-coin-collector}/main.cpp (100%) rename {u11264-Coin-Collector => u11264-coin-collector}/test (100%) rename {u11495-Bubbles-and-Buckets => u11495-bubbles-and-buckets}/Makefile (100%) rename {u11495-Bubbles-and-Buckets => u11495-bubbles-and-buckets}/main.cpp (100%) rename {u11495-Bubbles-and-Buckets => u11495-bubbles-and-buckets}/t1 (100%) rename {u11495-Bubbles-and-Buckets => u11495-bubbles-and-buckets}/tests (100%) rename {u116-Unidirectional-TSP => u116-unidirectional-tsp}/p116.c (100%) rename {u1262-Password => u1262-password}/Makefile (100%) rename {u1262-Password => u1262-password}/main.cpp (100%) rename {u1262-Password => u1262-password}/t1 (100%) rename {u1262-Password => u1262-password}/t2 (100%) rename {u1262-Password => u1262-password}/t21 (100%) rename {u1262-Password => u1262-password}/t3 (100%) rename {u1262-Password => u1262-password}/t4 (100%) rename {u1262-Password => u1262-password}/t5 (100%) rename {u231-Testing-the-CATCHER => u231-testing-the-catcher}/231.py (100%) rename {u441-Lotto => u441-lotto}/solve.py (100%) rename {u441-Lotto => u441-lotto}/t1 (100%) rename {u441-Lotto => u441-lotto}/t2 (100%) rename {u441-Lotto => u441-lotto}/tests (100%) rename {u482-Permuation-Arrays => u482-permuation-arrays}/Makefile (100%) rename {u482-Permuation-Arrays => u482-permuation-arrays}/main.cpp (100%) rename {u482-Permuation-Arrays => u482-permuation-arrays}/out (100%) rename {u482-Permuation-Arrays => u482-permuation-arrays}/t1 (100%) rename {u482-Permuation-Arrays => u482-permuation-arrays}/t2 (100%) rename {u482-Permuation-Arrays => u482-permuation-arrays}/tst (100%) rename {u642-Word-Amalgamation => u642-word-amalgamation}/642.py (100%) rename {u927-Integer-Sequences-from-Addition-of-Terms => u927-integer-sequences-from-addition-of-terms}/Makefile (100%) rename {u927-Integer-Sequences-from-Addition-of-Terms => u927-integer-sequences-from-addition-of-terms}/main.cpp (100%) rename {u927-Integer-Sequences-from-Addition-of-Terms => u927-integer-sequences-from-addition-of-terms}/t0 (100%) rename {u927-Integer-Sequences-from-Addition-of-Terms => u927-integer-sequences-from-addition-of-terms}/test (100%) diff --git a/README.md b/README.md index e5cbffc..b0ba304 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ Solutions to problems from various competitive programming sites. Beware of old, questionable-looking, code. * More general solutions can be found under the directory 'algorithms-and-datastructures' -* Problems found at 'Open Kattis' have been put in directory named after the problem title. +* Problems found at 'Open Kattis' have been put in directories named after the problem title. * Problems I could only find through 'Online Judge' (UVa) are prepended with a 'u' and the problem number at UVa. diff --git a/pseudoprime-numbers/main.cpp b/pseudoprime-numbers/main.cpp index 2fd1b5b..c4d39c8 100644 --- a/pseudoprime-numbers/main.cpp +++ b/pseudoprime-numbers/main.cpp @@ -1,22 +1,26 @@ #include +#include +#include typedef long long unsigned llu; bool isPrime(int n) { - if ( n == 2 || n == 3 ) + if ( n == 2 || n == 3 ) { return true; - else if ( n%2 == 0 || n%3 == 0) + } else if ( n%2 == 0 || n%3 == 0 ) { return false; + } long unsigned i=5, o=0, m=3; - while ( n != 1 && 0 < n && i < n/m) + while ( n != 1 && 0 < n && i < n/m ) { - if ( n%i == 0 ) + if( n%i == 0 ) { return false; + } m = i; - if ( i%6 == 5 ) { + if( i%6 == 5 ) { o++; i += 2; } else { @@ -28,21 +32,21 @@ bool isPrime(int n) llu repMod(const llu a, const llu p) { - if (p == 0) return 1; + if( p == 0 ) { return 1; } llu e = p; llu rem = 1; llu c = a; - while (1 <= e) + while( 1 <= e ) { - if (e % 2 == 1) + if( e % 2 == 1 ) { rem *= c; rem %= p; - if (--e == 0) return rem; + if( --e == 0 ) { return rem; } } c *= c; @@ -56,7 +60,7 @@ llu repMod(const llu a, const llu p) void isBAPP(int a, int p) { bool ans; - if ( isPrime(p)) + if ( isPrime(p) ) { ans = false; } @@ -77,12 +81,20 @@ void isBAPP(int a, int p) int main() { int p, a; - while (1) + + auto t_start = std::chrono::high_resolution_clock::now(); + while(1) { scanf("%d %d\n", &p, &a); - if (p == 0 && a == 0) { break; } // EXIT condition + if ( p == 0 && a == 0 ) { break; } // EXIT condition // Calc. isBAPP(a, p); } + auto t_stop = std::chrono::high_resolution_clock::now(); + + auto duration = std::chrono::duration_cast(t_stop - t_start); + + std::cout << "Duration: " << duration.count() << std::endl; } + diff --git a/u100-The-3n+1-Problem/p100.c b/u100-the-3n+1-problem/p100.c similarity index 100% rename from u100-The-3n+1-Problem/p100.c rename to u100-the-3n+1-problem/p100.c diff --git a/u10071-Back-to-High-School-Physics/Makefile b/u10071-back-to-high-school-physics/Makefile similarity index 100% rename from u10071-Back-to-High-School-Physics/Makefile rename to u10071-back-to-high-school-physics/Makefile diff --git a/u10071-Back-to-High-School-Physics/main.cpp b/u10071-back-to-high-school-physics/main.cpp similarity index 100% rename from u10071-Back-to-High-School-Physics/main.cpp rename to u10071-back-to-high-school-physics/main.cpp diff --git a/u10168-Summation-of-Four-Primes/Makefile b/u10168-summation-of-four-primes/Makefile similarity index 100% rename from u10168-Summation-of-Four-Primes/Makefile rename to u10168-summation-of-four-primes/Makefile diff --git a/u10168-Summation-of-Four-Primes/main.cpp b/u10168-summation-of-four-primes/main.cpp similarity index 100% rename from u10168-Summation-of-Four-Primes/main.cpp rename to u10168-summation-of-four-primes/main.cpp diff --git a/u10168-Summation-of-Four-Primes/tests b/u10168-summation-of-four-primes/tests similarity index 100% rename from u10168-Summation-of-Four-Primes/tests rename to u10168-summation-of-four-primes/tests diff --git a/u10684-The-Jackpot/Makefile b/u10684-the-jackpot/Makefile similarity index 100% rename from u10684-The-Jackpot/Makefile rename to u10684-the-jackpot/Makefile diff --git a/u10684-The-Jackpot/main.cpp b/u10684-the-jackpot/main.cpp similarity index 100% rename from u10684-The-Jackpot/main.cpp rename to u10684-the-jackpot/main.cpp diff --git a/u10684-The-Jackpot/t1 b/u10684-the-jackpot/t1 similarity index 100% rename from u10684-The-Jackpot/t1 rename to u10684-the-jackpot/t1 diff --git a/u10684-The-Jackpot/t2 b/u10684-the-jackpot/t2 similarity index 100% rename from u10684-The-Jackpot/t2 rename to u10684-the-jackpot/t2 diff --git a/u10684-The-Jackpot/t3 b/u10684-the-jackpot/t3 similarity index 100% rename from u10684-The-Jackpot/t3 rename to u10684-the-jackpot/t3 diff --git a/u10684-The-Jackpot/t4 b/u10684-the-jackpot/t4 similarity index 100% rename from u10684-The-Jackpot/t4 rename to u10684-the-jackpot/t4 diff --git a/u10812-Beat-the-Spread/Makefile b/u10812-beat-the-spread/Makefile similarity index 100% rename from u10812-Beat-the-Spread/Makefile rename to u10812-beat-the-spread/Makefile diff --git a/u10812-Beat-the-Spread/main.cpp b/u10812-beat-the-spread/main.cpp similarity index 100% rename from u10812-Beat-the-Spread/main.cpp rename to u10812-beat-the-spread/main.cpp diff --git a/u11264-Coin-Collector/Makefile b/u11264-coin-collector/Makefile similarity index 100% rename from u11264-Coin-Collector/Makefile rename to u11264-coin-collector/Makefile diff --git a/u11264-Coin-Collector/main.cpp b/u11264-coin-collector/main.cpp similarity index 100% rename from u11264-Coin-Collector/main.cpp rename to u11264-coin-collector/main.cpp diff --git a/u11264-Coin-Collector/test b/u11264-coin-collector/test similarity index 100% rename from u11264-Coin-Collector/test rename to u11264-coin-collector/test diff --git a/u11495-Bubbles-and-Buckets/Makefile b/u11495-bubbles-and-buckets/Makefile similarity index 100% rename from u11495-Bubbles-and-Buckets/Makefile rename to u11495-bubbles-and-buckets/Makefile diff --git a/u11495-Bubbles-and-Buckets/main.cpp b/u11495-bubbles-and-buckets/main.cpp similarity index 100% rename from u11495-Bubbles-and-Buckets/main.cpp rename to u11495-bubbles-and-buckets/main.cpp diff --git a/u11495-Bubbles-and-Buckets/t1 b/u11495-bubbles-and-buckets/t1 similarity index 100% rename from u11495-Bubbles-and-Buckets/t1 rename to u11495-bubbles-and-buckets/t1 diff --git a/u11495-Bubbles-and-Buckets/tests b/u11495-bubbles-and-buckets/tests similarity index 100% rename from u11495-Bubbles-and-Buckets/tests rename to u11495-bubbles-and-buckets/tests diff --git a/u116-Unidirectional-TSP/p116.c b/u116-unidirectional-tsp/p116.c similarity index 100% rename from u116-Unidirectional-TSP/p116.c rename to u116-unidirectional-tsp/p116.c diff --git a/u1262-Password/Makefile b/u1262-password/Makefile similarity index 100% rename from u1262-Password/Makefile rename to u1262-password/Makefile diff --git a/u1262-Password/main.cpp b/u1262-password/main.cpp similarity index 100% rename from u1262-Password/main.cpp rename to u1262-password/main.cpp diff --git a/u1262-Password/t1 b/u1262-password/t1 similarity index 100% rename from u1262-Password/t1 rename to u1262-password/t1 diff --git a/u1262-Password/t2 b/u1262-password/t2 similarity index 100% rename from u1262-Password/t2 rename to u1262-password/t2 diff --git a/u1262-Password/t21 b/u1262-password/t21 similarity index 100% rename from u1262-Password/t21 rename to u1262-password/t21 diff --git a/u1262-Password/t3 b/u1262-password/t3 similarity index 100% rename from u1262-Password/t3 rename to u1262-password/t3 diff --git a/u1262-Password/t4 b/u1262-password/t4 similarity index 100% rename from u1262-Password/t4 rename to u1262-password/t4 diff --git a/u1262-Password/t5 b/u1262-password/t5 similarity index 100% rename from u1262-Password/t5 rename to u1262-password/t5 diff --git a/u231-Testing-the-CATCHER/231.py b/u231-testing-the-catcher/231.py similarity index 100% rename from u231-Testing-the-CATCHER/231.py rename to u231-testing-the-catcher/231.py diff --git a/u441-Lotto/solve.py b/u441-lotto/solve.py similarity index 100% rename from u441-Lotto/solve.py rename to u441-lotto/solve.py diff --git a/u441-Lotto/t1 b/u441-lotto/t1 similarity index 100% rename from u441-Lotto/t1 rename to u441-lotto/t1 diff --git a/u441-Lotto/t2 b/u441-lotto/t2 similarity index 100% rename from u441-Lotto/t2 rename to u441-lotto/t2 diff --git a/u441-Lotto/tests b/u441-lotto/tests similarity index 100% rename from u441-Lotto/tests rename to u441-lotto/tests diff --git a/u482-Permuation-Arrays/Makefile b/u482-permuation-arrays/Makefile similarity index 100% rename from u482-Permuation-Arrays/Makefile rename to u482-permuation-arrays/Makefile diff --git a/u482-Permuation-Arrays/main.cpp b/u482-permuation-arrays/main.cpp similarity index 100% rename from u482-Permuation-Arrays/main.cpp rename to u482-permuation-arrays/main.cpp diff --git a/u482-Permuation-Arrays/out b/u482-permuation-arrays/out similarity index 100% rename from u482-Permuation-Arrays/out rename to u482-permuation-arrays/out diff --git a/u482-Permuation-Arrays/t1 b/u482-permuation-arrays/t1 similarity index 100% rename from u482-Permuation-Arrays/t1 rename to u482-permuation-arrays/t1 diff --git a/u482-Permuation-Arrays/t2 b/u482-permuation-arrays/t2 similarity index 100% rename from u482-Permuation-Arrays/t2 rename to u482-permuation-arrays/t2 diff --git a/u482-Permuation-Arrays/tst b/u482-permuation-arrays/tst similarity index 100% rename from u482-Permuation-Arrays/tst rename to u482-permuation-arrays/tst diff --git a/u642-Word-Amalgamation/642.py b/u642-word-amalgamation/642.py similarity index 100% rename from u642-Word-Amalgamation/642.py rename to u642-word-amalgamation/642.py diff --git a/u927-Integer-Sequences-from-Addition-of-Terms/Makefile b/u927-integer-sequences-from-addition-of-terms/Makefile similarity index 100% rename from u927-Integer-Sequences-from-Addition-of-Terms/Makefile rename to u927-integer-sequences-from-addition-of-terms/Makefile diff --git a/u927-Integer-Sequences-from-Addition-of-Terms/main.cpp b/u927-integer-sequences-from-addition-of-terms/main.cpp similarity index 100% rename from u927-Integer-Sequences-from-Addition-of-Terms/main.cpp rename to u927-integer-sequences-from-addition-of-terms/main.cpp diff --git a/u927-Integer-Sequences-from-Addition-of-Terms/t0 b/u927-integer-sequences-from-addition-of-terms/t0 similarity index 100% rename from u927-Integer-Sequences-from-Addition-of-Terms/t0 rename to u927-integer-sequences-from-addition-of-terms/t0 diff --git a/u927-Integer-Sequences-from-Addition-of-Terms/test b/u927-integer-sequences-from-addition-of-terms/test similarity index 100% rename from u927-Integer-Sequences-from-Addition-of-Terms/test rename to u927-integer-sequences-from-addition-of-terms/test