├── .gitattributes ├── .gitignore ├── CodeChef ├── CF224 - Polygon │ └── CF224 - Polygon.py ├── ECJAN20I - Psertu in Byteland │ └── Psertu in Byteland.py ├── KOL1509 - Save The Trees │ └── KOL1509 - Save The Trees.py ├── ROMANMCM - Roman numerals │ └── ROMANMCM - Roman numerals.py └── TEST - Life, the Universe, and Everything │ └── 1_Life, the Universe, and Everything.py ├── Contests ├── CENS2020 - Code Ensemble 2020 Division 2 │ ├── CENS20D - Priya and AND │ │ └── Priya and AND.py │ └── CENS20G - Help Martha │ │ └── Help Martha.py ├── JUNE20B - June Challenge 2020 Division 2 │ ├── CHFICRM - Chef and Icecream │ │ └── Chef and Icecream.py │ ├── CONTAIN - The Delicious Cake │ │ ├── CONTAIN - The Delicious Cake.py │ │ └── samples │ │ │ ├── input1.txt │ │ │ ├── input2.txt │ │ │ ├── output1.txt │ │ │ └── output2.txt │ ├── COVDSMPL - Covid Sampling (Challenge) │ │ └── COVDSMPL - Covid Sampling (Challenge).py │ ├── EOEO - The Tom and Jerry Game! │ │ └── The Tom and Jerry Game!.py │ ├── EVENM - Even Matrix │ │ └── Even Matrix.py │ ├── GUESSG - Guessing Game │ │ ├── GUESSG - Guessing Game.py │ │ ├── __pycache__ │ │ │ └── segment.cpython-38.pyc │ │ └── segment.py │ ├── PRICECON - Chef and Price Control │ │ └── Chef and Price Control.py │ ├── TTUPLE - Operations on a Tuple │ │ └── Operations on a Tuple.py │ └── XYSTR - Chef and String │ │ └── Chef and String.py ├── Kick Start 2020 - Round D │ ├── Alien Piano │ │ └── Alien Piano.py │ ├── Beauty of tree │ │ ├── Beauty of tree.py │ │ ├── Beauty of tree_v2.py │ │ ├── Beauty of tree_v3.py │ │ └── Beauty of tree_v4.py │ ├── Locked Doors │ │ ├── Locked Doors.py │ │ └── Locked Doors_v2.py │ └── Record Breaker │ │ └── Record Breaker.py ├── LEARNDSA - DSA Learning Series │ ├── Contest 1 │ │ ├── CARVANS - Carvans │ │ │ └── CARVANS - Carvans.py │ │ ├── CONFLIP - Coin Flip │ │ │ └── CONFLIP - Coin Flip.py │ │ ├── FCTRL - Factorial │ │ │ └── Factorial.py │ │ ├── FLOW007 - Reverse The Number │ │ │ └── Reverse The Number.py │ │ ├── LADDU - Laddu │ │ │ └── LADDU - Laddu.py │ │ ├── LAPIN - Lapindromes │ │ │ └── Lapindromes.py │ │ ├── MULTHREE - Multiple of 3 │ │ │ └── MULTHREE - Multiple of 3.py │ │ ├── TEST - Life, the Universe, and Everything │ │ │ └── Life, the Universe, and Everything.py │ │ └── ZCO14003 - Smart Phone │ │ │ └── ZCO14003 - Smart Phone.py │ ├── Contest 2 │ │ ├── CHFQUEUE - Chefs in Queue │ │ │ ├── Chefs in Queue_v1.py │ │ │ └── Chefs in Queue_v2.py │ │ ├── COMPILER - Compilers and parsers │ │ │ └── COMPILER - Compilers and parsers.py │ │ ├── INPSTFIX - Infix to Postfix │ │ │ └── Infix to Postfix.py │ │ ├── NOTALLFL - Not All Flavours │ │ │ └── Not All Flavours.py │ │ ├── PSHOT - Penalty Shoot-Out II │ │ │ └── Penalty Shoot-Out II.py │ │ ├── STFOOD - Chef and Street Food │ │ │ └── Chef and Street Food.py │ │ ├── STUPMACH - Stupid Machine │ │ │ └── Stupid Machine.py │ │ ├── ZCO12001 - Matched Brackets │ │ │ └── Matched Brackets.py │ │ ├── ZCO12002 - Wormholes │ │ │ └── ZCO12002 - Wormholes.py │ │ └── ZCO15004 - Rectangle │ │ │ └── ZCO15004 - Rectangle.py │ └── Contest 3 │ │ ├── DPAIRS - Distinct Pairs │ │ └── DPAIRS - Distinct Pairs.py │ │ ├── FENCE - Fencing │ │ └── FENCE - Fencing.py │ │ └── SAVKONO - Save Konoha │ │ └── SAVKONO - Save Konoha.py └── LTIME84B - May Lunchtime 2020 Division 2 │ ├── CONVSTR - Convert the String │ └── Convert the String.py │ ├── LOSTWKND - Lost Weekends │ └── Lost Weekends.py │ ├── TREDIFF - Tree difference │ └── Tree difference.py │ └── WWALK - Weird Walk │ └── Weird Walk.py ├── HackerRank ├── 15 Days of Learning SQL │ └── 15 Days of Learning SQL.sql ├── 30 Days of Code │ ├── Day 0 Hello, World │ │ └── 30 Hello, World.py │ ├── Day 1 Data Types │ │ └── Data Types.py │ ├── Day 10 Binary Numbers │ │ └── Binary Numbers.py │ ├── Day 11 2D Arrays │ │ └── 2D Arrays.py │ ├── Day 12 Inheritance │ │ └── Inheritance.py │ ├── Day 13 Abstract Classes │ │ └── Abstract Classes.py │ ├── Day 14 Scope │ │ └── Scope.py │ ├── Day 15 Linked List │ │ └── Linked List.py │ ├── Day 16 Exceptions - String to Integer │ │ └── Exceptions - String to Integer.py │ ├── Day 17 More Exceptions │ │ └── More Exceptions.py │ ├── Day 18 Queues and Stacks │ │ └── Queues and Stacks.py │ ├── Day 19 Interfaces │ │ └── Interfaces.py │ ├── Day 2 Operators │ │ └── Operators.py │ ├── Day 20 Sorting │ │ └── Sorting.py │ ├── Day 21 Generics │ │ └── Generics.cpp │ ├── Day 22 Binary Search Trees │ │ └── Binary Search Trees.py │ ├── Day 23 BST Level-Order Traversal │ │ └── BST Level-Order Traversal.py │ ├── Day 24 More Linked Lists │ │ └── More Linked Lists.py │ ├── Day 25 Running Time and Complexity │ │ └── Running Time and Complexity.py │ ├── Day 26 Nested Logic │ │ └── Nested Logic.py │ ├── Day 27 Testing │ │ └── Testing.py │ ├── Day 28 RegEx, Patterns, and Intro to Databases │ │ └── RegEx, Patterns, and Intro to Databases.py │ ├── Day 29 Bitwise AND │ │ └── Bitwise AND.py │ ├── Day 3 Intro to Conditional Statements │ │ └── Intro to Conditional Statements.py │ ├── Day 4 Class vs. Instance │ │ └── Class vs. Instance.py │ ├── Day 5 Loops │ │ └── Loops.py │ ├── Day 6 Let's Review │ │ └── Let's Review.py │ ├── Day 7 Arrays │ │ └── Arrays.py │ ├── Day 8 Dictionaries and Maps │ │ └── Dictionaries and Maps.py │ └── Day 9 Recursion 3 │ │ └── Recursion 3.py ├── A Very Big Sum │ └── A Very Big Sum.py ├── African Cities │ └── African Cities.sql ├── Alphabet Rangoli │ └── Alphabet Rangoli.py ├── Alternating Characters │ └── Alternating Characters.py ├── Apple and Orange │ └── Apple and Orange.py ├── Arithmetic Operators │ └── Arithmetic Operators.py ├── Array Manipulation │ └── Array Manipulation.py ├── Average Population of Each Continent │ └── Average Population of Each Continent.sql ├── Average Population │ └── Average Population.sql ├── Beautiful Binary String │ └── Beautiful Binary String.py ├── Between Two Sets │ └── Between Two Sets.py ├── Binary Tree Nodes │ └── Binary Tree Nodes.sql ├── Birthday Cake Candles │ └── Birthday Cake Candles.py ├── Calendar Module │ └── Calendar Module.py ├── Capitalize! │ └── Capitalize!.py ├── Challenges │ └── Challenges.sql ├── Collections.OrderedDict() │ └── Collections.OrderedDict().py ├── Collections.namedtuple() │ └── Collections.namedtuple().py ├── Company Logo │ └── Company Logo.py ├── Compare the Triplets │ └── Compare the Triplets.py ├── Compress the String! │ └── Compress the String!.py ├── Contest Leaderboard │ └── Contest Leaderboard.sql ├── Count Triplets │ └── Count Triplets.py ├── Counting Valleys │ └── Counting Valleys.py ├── DefaultDict Tutorial │ └── DefaultDict Tutorial.py ├── Designer Door Mat │ └── Designer Door Mat.py ├── Diagonal Difference │ └── Diagonal Difference.py ├── Draw The Triangle 1 │ └── Draw The Triangle 1.sql ├── Draw The Triangle 2 │ └── Draw The Triangle 2.sql ├── Employee Names │ └── Employee Names.sql ├── Employee Salaries │ └── Employee Salaries.sql ├── Find Angle MBC │ └── Find Angle MBC.py ├── Find a string │ └── Find a string.py ├── Find the Runner-Up Score! │ └── Find the Runner-Up Score!.py ├── Finding the percentage │ └── Finding the percentage.py ├── Fraudulent Activity Notifications │ └── Fraudulent Activity Notifications.py ├── Frequency Queries │ └── Frequency Queries.py ├── Gemstones │ └── Gemstones.py ├── Grading Students │ └── Grading Students.py ├── Hackerland Radio Transmitters │ └── Hackerland Radio Transmitters.py ├── Hash Tables - Ransom Note │ └── Hash Tables - Ransom Note.py ├── Higher Than 75 Marks │ └── Higher Than 75 Marks.sql ├── Highest Value Palindrome │ └── Highest Value Palindrome.py ├── Insertion Sort Advanced Analysis │ └── Insertion Sort Advanced Analysis.py ├── Interviews │ └── Interviews.sql ├── Iterables and Iterators │ └── Iterables and Iterators.py ├── Japan Population │ └── Japan Population.sql ├── Japanese Cities' Attributes │ └── Japanese Cities' Attributes.sql ├── Japanese Cities' Names │ └── Japanese Cities' Names.sql ├── Jumping on the Clouds │ └── Jumping on the Clouds.py ├── Kangaroo │ └── Kangaroo.py ├── Lily's Homework │ └── Lily's Homework.py ├── List Comprehensions │ └── List Comprehensions.py ├── Lists │ └── Lists.py ├── Loops │ └── Loops.py ├── Mark and Toys │ └── Mark and Toys.py ├── Maximize It! │ └── Maximize It!.py ├── Merge Sort Counting Inversions │ └── Merge Sort Counting Inversions.py ├── Mini-Max Sum │ └── Mini-Max Sum.py ├── Mod Divmod │ └── Mod Divmod.py ├── Mutations │ └── Mutations.py ├── Nested Lists │ └── Nested Lists.py ├── New Companies │ └── New Companies.sql ├── Occupations │ └── Occupations.sql ├── Ollivander's Inventory │ └── Ollivander's Inventory.sql ├── Placements │ └── Placements.sql ├── Plus Minus │ └── Plus Minus.py ├── Polar Coordinates │ └── Polar Coordinates.py ├── Population Census │ └── Population Census.sql ├── Population Density Difference │ └── Population Density Difference.sql ├── Print Function │ └── Print Function.py ├── Print Prime Numbers │ └── Print Prime Numbers.sql ├── Python Division │ └── Python Division.py ├── Python If-Else │ └── Python If-Else.py ├── Repeated String │ └── Repeated String.py ├── Revising Aggregations - Averages │ └── Revising Aggregations - Averages.sql ├── Revising Aggregations - The Count Function │ └── Revising Aggregations - The Count Function.sql ├── Revising Aggregations - The Sum Function │ └── Revising Aggregations - The Sum Function.sql ├── Revising the Select Query I │ └── Revising the Select Query I.sql ├── Revising the Select Query II │ └── Revising the Select Query II.sql ├── SQL Project Planning │ └── SQL Project Planning.sql ├── Say Hello, World! With Python │ └── Say Hello, World! With Python.py ├── Select All │ └── Select All.sql ├── Select By ID │ └── Select By ID.sql ├── Sherlock and Anagrams │ └── Sherlock and Anagrams.py ├── Sherlock and the Valid String │ └── Sherlock and the Valid String.py ├── Simple Array Sum │ └── Simple Array Sum.py ├── Sock Merchant │ └── Sock Merchant.py ├── Sorting Bubble Sort │ └── Sorting Bubble Sort.py ├── Sorting Comparator │ └── Sorting Comparator.py ├── Staircase │ └── Staircase.py ├── String Formatting │ └── String Formatting.py ├── String Split and Join │ └── String Split and Join.py ├── String Validators │ └── String Validators.py ├── Strings Making Anagrams │ └── Strings Making Anagrams.py ├── Symmetric Pairs │ └── Symmetric Pairs.sql ├── Text Alignment │ └── Text Alignment.py ├── Text Wrap │ └── Text Wrap.py ├── The Blunder │ └── The Blunder.sql ├── The Love-Letter Mystery │ └── The Love-Letter Mystery.py ├── The PADS │ └── The PADS.sql ├── The Report │ └── The Report.sql ├── Time Conversion │ └── Time Conversion.py ├── Top Competitors │ └── Top Competitors.sql ├── Top Earners │ └── Top Earners.sql ├── Triangle Quest 2 │ └── Triangle Quest 2.py ├── Tuples │ └── Tuples.py ├── Two Strings │ └── Two Strings.py ├── Type of Triangle │ └── Type of Triangle.sql ├── Weather Observation Station 1 │ └── Weather Observation Station 1.sql ├── Weather Observation Station 10 │ └── Weather Observation Station 10.sql ├── Weather Observation Station 11 │ └── Weather Observation Station 11.sql ├── Weather Observation Station 12 │ └── Weather Observation Station 12.sql ├── Weather Observation Station 13 │ └── Weather Observation Station 13.sql ├── Weather Observation Station 14 │ └── Weather Observation Station 14.sql ├── Weather Observation Station 15 │ └── Weather Observation Station 15.sql ├── Weather Observation Station 16 │ └── Weather Observation Station 16.sql ├── Weather Observation Station 17 │ └── Weather Observation Station 17.sql ├── Weather Observation Station 18 │ └── Weather Observation Station 18.sql ├── Weather Observation Station 19 │ └── Weather Observation Station 19.sql ├── Weather Observation Station 2 │ └── Weather Observation Station 2.sql ├── Weather Observation Station 20 │ └── Weather Observation Station 20.sql ├── Weather Observation Station 3 │ └── Weather Observation Station 3.sql ├── Weather Observation Station 4 │ └── Weather Observation Station 4.sql ├── Weather Observation Station 5 │ └── Weather Observation Station 5.sql ├── Weather Observation Station 6 │ └── Weather Observation Station 6.sql ├── Weather Observation Station 7 │ └── Weather Observation Station 7.sql ├── Weather Observation Station 8 │ └── Weather Observation Station 8.sql ├── Weather Observation Station 9 │ └── Weather Observation Station 9.sql ├── What's Your Name │ └── What's Your Name.py ├── Write a function │ └── Write a function.py ├── collections.Counter() │ └── collections.Counter().py ├── itertools.combinations() │ └── itertools.combinations().py ├── itertools.combinations_with_replacement() │ └── itertools.combinations_with_replacement().py ├── itertools.permutations() │ └── itertools.permutations().py ├── itertools.product() │ └── itertools.product().py └── sWAP cASE │ └── sWAP cASE.py ├── Kaggle └── Titanic - Machine Learning from Disaster │ └── Getting Started with Titanic.ipynb ├── README.md ├── SPOJ ├── ABCDEF - ABCDEF │ └── ABCDEF.java ├── ABSP1_abs(a-b) I │ └── ABSP1.java ├── ABSYS - Anti-Blot System │ └── Anti-Blot System.py ├── ACMT - Acm Teams │ └── Acm Teams.R ├── ACODE - Alphacode │ └── ACODE.java ├── ACPC10A_What’s Next │ └── ACPC10A.java ├── ACPC10B - Sum the Square │ └── ACPC10B.java ├── ACPC10D - Tri graphs │ └── ACPC10D.java ├── ACPC11B - Between the Mountains │ └── ACPC11B.java ├── ACPC11C - Circleland │ └── ACPC11C.java ├── ACQUIRE - Land Acquisition │ └── Land Acquisition.py ├── ADAM1 - Adrita and Marbles │ └── ADAM1.java ├── ADASEQEN _Ada and Subsequence │ └── ADASEQEN.java ├── ADDREV_Adding Reversed Numbers │ ├── 42_Adding Reversed Numbers.R │ ├── 42_Adding Reversed Numbers.py │ ├── 42_Adding Reversed Numbers.sh │ └── ADDREV.java ├── ADV04J - Invisible point │ └── Invisible point.py ├── AE00_Rectangles │ └── Rectangles.R ├── AE1B_Tables │ └── Tables.py ├── AGGRCOW - Aggressive cows │ └── AGGRCOW.java ├── AGPC01F - Can you search │ └── Can you search.py ├── AGPREFX - Agent prefix │ └── Agent prefix.py ├── ALCATRAZ1_Sum of digits │ ├── Sum of digits.R │ └── Sum of digits.py ├── ALICESIE - Alice Sieve │ ├── ALICESIE.java │ └── Alice Sieve.sh ├── AMR10G_Christmas Play │ └── Christmas Play.py ├── AMR11E - Distinct Primes │ └── Distinct Primes.py ├── AMR12D_The Mirror of Galadriel │ └── AMR12D.java ├── ANARC08B - Adding Sevens │ └── Adding Sevens.py ├── ANARC08E - Relax! It is just a game │ └── Relax! It is just a game.py ├── ANARC09B - Tiles of Tetris, Not! │ └── Tiles of Tetris, Not!.py ├── APS - Amazing Prime Sequence │ └── Amazing Prime Sequence.py ├── ARABICNUM - Arabic Numbers │ └── Arabic Numbers.py ├── ARITH - Simple Arithmetics │ └── Simple Arithmetics.py ├── ARITH2_Simple Arithmetics II │ └── ARITH2.java ├── ARMY - Army Strength │ └── Army Strength.py ├── ARRANGE - Arranging Amplifiers │ └── Arranging Amplifiers.py ├── AVG - AVERAGE │ └── AVERAGE.py ├── AVRG - Simple Average │ └── Simple Average.py ├── BABA1 - ARE YOU GOOD IN MATHS │ └── ARE YOU GOOD IN MATHS.py ├── BACTERIA - SPOJ Custom Test │ └── SPOJ Custom Test.sh ├── BAISED - Biased Standings │ ├── BAISED.java │ └── Biased Standings.py ├── BALLSUM_Ball sum │ └── Ball sum.py ├── BEENUMS - Beehive Numbers │ └── BEENUMS.java ├── BFALG - Brute-force Algorithm EXTREME │ ├── BFALG.java │ └── BFALG2.java ├── BFWRITE - Brainf F##k Writing │ └── Brainf F##k Writing.bf ├── BFXYZ - BrainFked │ └── BrainFked.bf ├── BINARYIO - Binary Input and Output │ ├── Binary Input and Output.cpp │ ├── Binary Input and Output.py │ ├── Binary Input and Output_v2.cpp │ ├── Binary Input and Output_v2.py │ └── Binary Input and Output_v3.py ├── BINSTIRL - Binary Stirling Numbers │ └── Binary Stirling Numbers.sh ├── BISHOPS_Bishops │ └── Bishops.R ├── BOGGLE - Boggle Scoring │ └── Boggle Scoring.py ├── BOKAM143SOU - Checking cubes │ └── Checking cubes.py ├── BOOKGFT_Book Gift │ └── Book Gift.py ├── BSCXOR_XOR │ └── XOR.sh ├── BSEARCH1 - Binary search │ └── BSEARCH1.java ├── BTCODE_F - Life Game │ └── BTCODE_F.java ├── BUET19_Map │ ├── 35355_Map.cpp │ └── 35355_Map.py ├── BUGTEST - Tutorial for Your Rank is Pure (EXTREME ver) │ └── Tutorial for Your Rank is Pure (EXTREME ver).py ├── BUYINT - Buying Integers │ └── BUYINT.java ├── BWIDOW_Black Widow Rings │ ├── Black Widow Rings 2.R │ └── Black Widow Rings.R ├── BYTESM2 - Philosophers Stone │ └── BYTESM2.java ├── CANDY3_Candy III │ └── Candy III.py ├── CANDY_Candy I │ └── CANDY.java ├── CANTON - Count on Cantor │ └── Count on Cantor.py ├── CATXAT - CAT and XAT │ └── CAT and XAT.sh ├── CDRSANJ - CODER FIRST PROBLEM │ └── CODER FIRST PROBLEM.sh ├── CEQU - Crucial Equation │ └── CEQU.java ├── CHITEST1_Sum of two numbers │ └── Sum of two numbers.sh ├── CHI_EXP - The real exponential │ ├── CHI_EXP - The real exponential_v1.py │ └── CHI_EXP - The real exponential_v2.py ├── CHI_LOG - The real logarithm │ └── The real logarithm.py ├── CHI_SIN - The real sine │ └── CHI_SIN - The real sine.py ├── CIRCLEDIV - Euler Puzzle │ └── CIRCLEDIV.java ├── CLOCK2 - The Famous Clock │ └── The Famous Clock.py ├── CLOPPAIR_Closest Point Pair │ ├── Closest Point Pair.cpp │ └── Closest Point Pair.py ├── CODECODE - Coder Or NonCoder │ └── Coder Or NonCoder.R ├── CODEM1 - Problem1 │ ├── Problem1.py │ └── Problem1.sh ├── CODEM2 - Problem2 │ └── Problem2.sh ├── CODEM3 - Problem3 │ └── Problem3.py ├── CODEM5 - Problem5 │ ├── Problem5.py │ └── Problem5_v2.py ├── CODESPTB_Insertion Sort │ └── Insertion Sort.py ├── COINS - Bytelandian gold coins │ └── COINS.java ├── COOLIT - Conta gli oggetti vecchi │ └── Conta gli oggetti vecchi.py ├── CORN - Corn Headache │ ├── Corn Headache.cpp │ └── Corn Headache_v2.cpp ├── CPCRC1C - Sum of Digits │ └── Sum of Digits.py ├── CPP_Closest Pair Problem │ └── Closest Pair Problem.py ├── CPRIME - Prime Number Theorem │ └── CPRIME.java ├── CPTTRN1 - Character Patterns (Act 1) │ └── Character Patterns (Act 1).py ├── CPTTRN2 - Character Patterns (Act 2) │ └── Character Patterns (Act 2).py ├── CPTTRN3 - Character Patterns (Act 3) │ └── Character Patterns (Act 3).py ├── CPTTRN4 - Character Patterns (Act 4) │ └── Character Patterns (Act 4).py ├── CPTTRN5 - Character Patterns (Act 5) │ └── Character Patterns (Act 5).py ├── CPTTRN6 - Character Patterns (Act 6) │ └── Character Patterns (Act 6).py ├── CPTTRN7 - Character Patterns (Act 7) │ └── CPTTRN7.java ├── CPTTRN8_Character Patterns (Act 8) │ └── CPTTRN8.java ├── CRDS - Cards │ └── Cards.R ├── CRS - Crying Series │ └── Crying Series.py ├── CRZYSMKR_Crazy Smoker │ └── CRZYSMKR.java ├── CSHOWB_Sir and the Guitar │ ├── CSHOWB.java │ └── CSHOWB2.java ├── CSUMQ - Cumulative Sum Query │ └── Cumulative Sum Query.py ├── CTRICK - Card Trick │ └── CTRICK.py ├── CUBES_Perfect Cubes │ └── Perfect Cubes.py ├── CUBNUM - Cube Numbers │ └── CUBNUM.java ├── DAYOUT2A - Reverse Words │ └── Reverse Words.sh ├── DAYOUT2B - Binary │ └── Binary.sh ├── DAYOUT2C - Prime Or Not │ └── Prime Or Not.py ├── DAYOUT2D - Dragons │ └── Dragons.sh ├── DAYOUT2E - Big Dragons │ └── Big Dragons.sh ├── DAYOUT2F - More Dragons │ └── More Dragons.sh ├── DAYOUT2G - Find Them All │ └── Find Them All.sh ├── DAYOUT2H - How Many Primes │ └── How Many Primes.sh ├── DCEPCA03 - Totient Extreme │ ├── DCEPCA03.java │ └── DCEPCA032.java ├── DCRYPT - Decrypt the message ! │ └── DCRYPT.java ├── DELEVE - Somma i numeri dispari │ └── Somma i numeri dispari.py ├── DIEHARD - DIE HARD │ └── DIE HARD.py ├── DIVSUM - Divisor Summation │ └── DIVSUM.java ├── DOL - Largest Odd Divisor │ └── Largest Odd Divisor.py ├── DRNTEAGL - Duronto Eagle │ └── DRNTEAGL.java ├── EASYMRKS_Easy Marks │ └── 25306_Easy Marks.py ├── EASYPROB_A Very Easy Problem! │ └── A Very Easy Problem!.R ├── EBOXES - Empty Boxes │ └── Empty Boxes.sh ├── EC_CONB_Even Numbers │ └── Even Numbers.py ├── EDIST - Edit distance │ └── Edit distance.py ├── EDS_Electronic Document Security │ └── Electronic Document Security.py ├── EIGHTS_Triple fat ladies │ └── Triple fat ladies.R ├── EKO - Eko │ └── EKO.java ├── ENCAROC - Occurrences of a Character │ └── Occurrences of a Character.py ├── ENGCD - Greatest Common Divisor │ └── Greatest Common Divisor.py ├── ENIGMATH - PLAY WITH MATH │ ├── PLAY WITH MATH.R │ └── PLAY WITH MATH_v2.R ├── ENLCD - Lowest Common Denominator │ └── Lowest Common Denominator.py ├── ENPRIME - Prime Number │ └── Prime Number.py ├── ETF - Euler Totient Function │ └── ETF.java ├── EXPECT - Life, the Universe, and Everything (Interactive) │ ├── Life, the Universe, and Everything (Interactive).py │ └── Life, the Universe, and Everything (Interactive).sh ├── FACEFRND_Friends of Friends │ └── FACEFRND.java ├── FANCY - FANCY NUMBER │ └── FANCY.java ├── FASHION_Fashion Shows │ └── Fashion shows.py ├── FAST2 - Fast Sum of two to an exponent │ └── Fast Sum of two to an exponent.py ├── FCTRL2_Small factorials │ ├── 24_Small factorials.R │ ├── 24_Small factorials.py │ └── FCTRL2.java ├── FCTRL_Factorial │ ├── 11_Factorial.R │ ├── 11_Factorial.py │ ├── 11_Factorial.sh │ └── FCTRL.java ├── FENCE1 - Build a Fence │ └── FENCE1.java ├── FIB64_64bit Fibonacci │ ├── FIB64S12.java │ ├── FIB64S3.java │ └── FIB64S5.java ├── FIBEZ_Easy Fibonacci │ └── Easy Fibonacci.py ├── FIBFUNCH - Fun with Fibonacci Series (Challenge) │ └── FIBFUNCH.java ├── FIBOFUN - Fun with Fibonacci Series │ └── FIBOFUN.java ├── FIBONOMIAL - Fibonacci Polynomial │ └── FIBONOMIAL.java ├── FIBOSQRT - Fibonacci With a Square Root │ ├── FIBOSQRT.java │ └── FIBOSQRT2.java ├── FIBOSUM - Fibonacci Sum │ └── FIBOSUM.java ├── FIBPOL - Fibonacci Polynomial │ └── FIBPOL.java ├── FIBTWIST - Fibonacci With a Twist │ └── FIBTWIST.java ├── FINDPRM - Finding Primes │ ├── Finding Primes.cpp │ ├── Finding Primes_v2.cpp │ └── Finding Primes_v3.cpp ├── FLOG - Find Log │ └── Find Log.py ├── FRNDZND_Friend Zoned │ └── FRNDZND.java ├── G10185 - TrianguloRectangulo Grado 10 │ └── TrianguloRectangulo Grado 10.py ├── G11 - Binario │ └── Binario.py ├── GCDEX - GCD Extreme │ └── GCDEX.java ├── GCJPURE - Your Rank is Pure │ └── Your Rank is Pure.py ├── GCPC11F - Diary │ └── GCPC11F.java ├── GDCOFTI - Greatest Common Divisor Of Three Integers │ └── Greatest Common Divisor Of Three Integers.py ├── GGD - Mr Toothless and His GCD Operation │ └── Mr Toothless and His GCD Operation.py ├── GLJIVE_Mushrooms problem │ └── Mushrooms problem.R ├── GMSTRE_Game Store │ └── Game Store.py ├── GNY07A - Mispelling │ └── Mispelling.py ├── GOO - Game Of Ones │ └── Game Of Ones.sh ├── GUANGGUN - 111…1 Squared │ └── 111…1 Squared.sh ├── HACKRNDM - Hacking the random number generator │ └── HACKRNDM.java ├── HAMSTER1 - Hamster flight │ └── Hamster flight.cpp ├── HANGOVER - Hangover │ └── HANGOVER.java ├── HAPPYTL - Happy Telephones │ └── HAPPYTL.java ├── HCOUPLE - Hidden Couple │ └── HCOUPLE.java ├── HEPNUM_Heptadecimal Numbers │ └── Heptadecimal Numbers.py ├── HISTOGRA - Largest Rectangle in a Histogram │ └── Largest Rectangle in a Histogram.py ├── HMBY_Hablu Wants to Buy │ └── Hablu Wants to Buy.R ├── HPYNOS - Happy Numbers I │ └── Happy Numbers I.py ├── HS12HDPW - Hidden Password │ └── HS12HDPW.java ├── HS12MBR - Minimum Bounding Rectangle │ └── Minimum Bounding Rectangle.py ├── HUBULLU - Hubulullu │ └── Hubulullu.sh ├── HYDRO - Hydroelectric dams │ └── Hydroelectric dams.py ├── ICANDIES - Candies │ └── ICANDIES.java ├── IEEEBGAM_The Ball Game │ ├── The Ball Game.R │ └── The Ball Game.py ├── IIITD1 - Those College Days! │ └── Those College Days!.py ├── IITKWPCB - Check the coprimeness │ └── Check the coprimeness.py ├── INFINITY - Biggest ! │ ├── Biggest !.c │ └── Biggest !.cpp ├── INFSUC - Basics │ ├── Basics.c │ └── Basics_v2.c ├── INOROUT - Inside or outside │ ├── Inside or outside.py │ └── samples │ │ ├── input1.txt │ │ ├── input2.txt │ │ ├── output1.txt │ │ └── output2.txt ├── INS17M - Fibonacci and Easy GCD │ └── Fibonacci and Easy GCD.py ├── INTEST - Enormous Input Test │ ├── Enormous Input Test.R │ ├── Enormous Input Test.py │ ├── INTEST.java │ ├── INTEST2.java │ └── INTEST3.java ├── INVCNT_Inversion Count │ └── INVCNT.java ├── JADDOU3 - Jaddouic Sequence │ └── Jaddouic Sequence.py ├── JC15A_Windy Cannon │ └── Windy Cannon.R ├── JOSWAP - Just One Swap │ └── Just One Swap.py ├── JULKA - Julka │ └── Julka.py ├── KIDZEE1B - Sum It Up │ └── Sum It Up.sh ├── KIDZEE1C - Multiple of 3 │ └── Multiple of 3.sh ├── KIDZEE1D - Great Grading Scheme │ └── Great Grading Scheme.sh ├── KIDZEE1E - Sort them All │ └── Sort them All.sh ├── KIDZEE1F - Easy as Cake │ └── Easy as Cake.sh ├── KIDZEE1G - Multiples │ └── Multiples.sh ├── KIDZEE1H - Digital Triangle │ └── Digital Triangle.sh ├── KIDZEE1I - In Love with Loops │ └── In Love with Loops.sh ├── KIDZEE1J - Divisors │ └── Divisors.sh ├── KIDZEE1K - Fun Triangle │ └── Fun Triangle.sh ├── KIDZEE1L - Progression │ └── KIDZEE1L.java ├── KIDZEE1M - Seconds Apart │ └── Seconds Apart.sh ├── KIDZEE1N - Rectangle Intersection │ └── Rectangle Intersection.sh ├── KIDZEE1O - Kings on an Infinite Chessboard │ └── Kings on an Infinite Chessboard.sh ├── KIDZEE1P - Progression │ └── Progression.sh ├── KLUG1 - COUNT JUMPS │ └── KLUG1.java ├── KNJIGE - KNJIGE │ └── KNJIGE.py ├── KOPC12A - K12 - Building Construction │ └── K12 - Building Construction.py ├── LASTDIG - The last digit │ └── The last digit.sh ├── LASTDIG2 - The last digit re-visited │ └── The last digit re-visited.py ├── LAWNMWR - Lawn Mower │ └── LAWNMWR.java ├── LCMSUM - LCM Sum │ └── LCMSUM.java ├── LG - LCM Game │ └── LG.java ├── LGIC - LOGIC │ └── LOGIC.py ├── LOOPEXP - Loop Expectation │ └── Loop Expectation.py ├── M3TILE - LATGACH3 │ └── LATGACH3.py ├── MADODDSUM_Easy Odd Sum │ └── Easy Odd Sum.py ├── MAGGNUM - Trova il numero maggiore │ └── Trova il numero maggiore.py ├── MAIN12A_SelfDescribingSequenceProblem │ └── SelfDescribingSequenceProblem.py ├── MAJOR - Majority │ └── Majority.py ├── MAJSTOR_Majstor │ └── MAJSTOR.java ├── MANGOES - Real Mangoes for Ranjith │ └── Real Mangoes for Ranjith.sh ├── MARBLES - Marbles │ ├── MARBLES.java │ └── Marbles.py ├── MASUM01 - Fame seeker Masum │ └── Fame seeker Masum.py ├── MATCHSTR - Tìm xâu 01 │ └── Tìm xâu 01.cpp ├── MATEX - Matrix Exponentiation │ ├── MATEX1.java │ ├── MATEX2.java │ └── MATEX3.java ├── MATHII - Yet Another Mathematical Problem │ └── MATHII.java ├── MATHLOVE_Math is Love │ └── MATHLOVE.java ├── MAXLN - THE MAX LINES │ └── THE MAX LINES.sh ├── MCDLUS - Massimo Comune Divisore │ └── Massimo Comune Divisore.py ├── MCOINS - Coins Game │ └── Coins Game.py ├── MEANSTRIC - Tricky Means │ ├── Tricky Means.cpp │ └── Tricky Means.py ├── MESSAGEC - Message Relay │ └── Message Relay.py ├── MFLAR10 - Flowers Flourish from France │ └── Flowers Flourish from France.py ├── MINSTACK - Smallest on the Stack │ ├── MINSTACK.java │ └── Smallest on the Stack.cpp ├── MISERMAN - Wise And Miser │ └── MISERMAN.java ├── MMASS - Mass of Molecule │ └── Mass of Molecule.py ├── MMAXPER - Rectangles Perimeter │ ├── Rectangles Perimeter.py │ └── Rectangles Perimeter_v2.py ├── MMFBTEAM - Big team formation │ └── MMFBTEAM.java ├── MMFTEAM - Team formation │ └── MMFTEAM.java ├── MOZGEOL - Jenny the GeoLover │ └── Jenny the GeoLover.py ├── MOZMTF - Mozahid the forgetful │ └── Mozahid the forgetful.py ├── MOZPAS - Prangon and String │ └── Prangon and String.py ├── MOZSACP - Sharmeen And C Programming │ └── Sharmeen And C Programming.sh ├── MOZSAEO - Sharmeen and Even Odd │ └── Sharmeen and Even Odd.sh ├── MOZSAHTF - Sharmeen And Her Two Friends │ └── Sharmeen And Her Two Friends.sh ├── MOZSAMSA - Sharmmen and Max Subarray │ └── Sharmmen and Max Subarray.py ├── MOZSAO - Sharmeen and One │ └── Sharmeen and One.py ├── MOZSAS - Shahadat and Sequence │ └── Shahadat and Sequence.py ├── MOZSATDOW - Sharmeen and the day of week │ ├── Sharmeen and the day of week.py │ └── Sharmeen and the day of week.sh ├── MOZSATLA - Sharmeen and the Lost Array │ └── Sharmeen and the Lost Array.py ├── MOZSLM - Sharmeen Loves Mozahid Loves Sharmeen [ EASY ] │ └── Sharmeen Loves Mozahid Loves Sharmeen [ EASY ].py ├── MPOW - Power of matrix │ └── Power of matrix.py ├── MRECAMAN - Recaman’s Sequence │ └── MRECAMAN.java ├── MUL - Fast Multiplication │ └── Fast Multiplication.py ├── MXMNDF - Differenza tra massimo e minimo in una lista │ └── Differenza tra massimo e minimo in una lista.py ├── NEWTANK - Tanks │ └── Tanks.sh ├── NGM - A Game with Numbers │ └── A Game with Numbers.sh ├── NODESC1 - No Description 1 │ └── No Description 1.py ├── NPC2014F - Field │ └── NPC2014F.java ├── NSORT - Name Sorting │ └── Name Sorting.py ├── NSTEPS_Number Steps │ └── Number Steps.py ├── NSYSTEM_Numeral System │ └── Numeral System.py ├── NUMPATH - Gutibazi │ └── NUMPATH.sh ├── NY10A_Penney Game │ └── Penney Game.py ├── OFORTUNE - Ohgas' Fortune │ └── Ohgas' Fortune.py ├── OMWG_One more weird game │ └── One more weird game.R ├── ONEZERO - Ones and zeros │ └── Ones and zeros.py ├── ONP_Transform the Expression │ └── Transform the Expression.R ├── OPCPIZZA - Pizzamania │ └── OPCPIZZA.java ├── ORTL1P04 - Average │ └── Average.R ├── OVGDEL - Good Elements │ └── Good Elements.py ├── P3EXLV1 - Somma tra due numeri │ └── Somma tra due numeri.py ├── P3LV0PRINT - Stringa maiuscola │ └── Stringa maiuscola.py ├── PAIRS1 - Count the Pairs │ └── PAIRS1.java ├── PARKET1_PARKET │ └── PARKET1.java ├── PCROSS1 - Cross Pattern (Act 1) │ └── PCROSS1.java ├── PCROSS2 - Cross Pattern (Act 2) │ └── PCROSS2.java ├── PGR01 - Progressions │ └── Progressions.py ├── PIVAL - Digits of Pi │ ├── Digits of Pi.py │ ├── Digits of Pi2.py │ └── Digits of Pi3.py ├── PL - Palindrome Lover │ └── PL.java ├── PLAYGAME_PLAYGAME │ └── PLAYGAME.py ├── PLCNUM1_Place the Numbers I │ └── 4245_Place the Numbers I.R ├── PLD_Palindromes │ └── PLD.java ├── POLCONST_Constructible Regular Polygons │ └── Constructible Regular Polygons.py ├── POLYMUL - Polynomial Multiplication │ ├── POLYMUL.java │ └── POLYMUL2.java ├── PON - Prime or Not │ └── Prime or Not.py ├── PPATH - Prime Path │ └── Prime Path.py ├── PPBRQ - Rotating Cube │ └── PPBRQ.java ├── PR003004 - Digit Sum │ └── PR003004.java ├── PRADIPSUM - Easy Math │ └── PRADIPSUM.py ├── PRIME1_Prime Generator │ ├── 2_Prime Generator.R │ ├── 2_Prime Generator.py │ └── PRIME1.java ├── PRIONPRI - Prime or not Prime! │ └── Prime or not Prime!.py ├── PRJAN15A - An Arithmetic Problem │ └── An Arithmetic Problem.sh ├── PT07Y - Is it a tree │ └── PT07Y.java ├── QUEUEEZ - Easy Queue │ └── QUEUEEZ.java ├── QWERTY01 - How many words(SHELL) │ ├── How many words(SHELL).sh │ ├── How many words(SHELL)_v2.sh │ └── How many words(SHELL)_v3.sh ├── QWERTY02 - BF writing │ └── BF writing.bf ├── QWERTY03 - Java counting │ └── QWERTY03.java ├── RANDMOD - Random modulo n │ └── Random modulo n.py ├── REPROAD - Repair road │ └── Repair road.py ├── RETO2 - TIEMPO JUNTOS grado 10 │ └── TIEMPO JUNTOS grado 10.py ├── REX - RegExp Master │ └── RegExp Master.txt ├── ROMAN008 - ROMAN NUMERALS │ └── ROMAN NUMERALS.py ├── ROMANN - Roman Numerals │ └── Roman Numerals.py ├── RPLE - Espionage │ ├── RPLE.java │ └── RPLE2.java ├── RPNEVAL - Evaluate simple RPN expression │ └── Evaluate simple RPN expression.py ├── RREVERSE - Reverse │ └── Reverse.py ├── RUHUL2 - Simple Sum │ └── Simple Sum.sh ├── S1P4 - Celebration │ └── Celebration.py ├── SAMER08E - Electricity │ └── SAMER08E.java ├── SAMER08F_Feynman │ └── SAMER08F.java ├── SBANK - Sorting Bank Accounts │ ├── Sorting Bank Accounts.R │ └── Sorting Bank Accounts.py ├── SCPC11B_Alaska │ └── Alaska.py ├── SEC01 - Join │ ├── Join.py │ └── Join.sh ├── SEQ - Recursive Sequence │ └── SEQ.py ├── SEQAGAIN - Easy Sequence! │ └── SEQAGAIN.java ├── SILVER - Cut the Silver Bar │ └── SILVER.java ├── SIZECON - Size Contest │ └── Size Contest.py ├── SMPCIRC - Two Circles │ └── SMPCIRC.java ├── SMPCPH1 - Substitution cipher │ └── Substitution cipher.py ├── SMPDIV - Divisibility │ └── SMPDIV.java ├── SMPSEQ3 - Fun with Sequences │ └── Fun with Sequences.py ├── SMPSEQ4 - Fun with Sequences (Act 2) │ └── Fun with Sequences (Act 2).py ├── SMPSEQ5_Fun with Sequences (Act 3) │ └── Fun with Sequences (Act 3).R ├── SMPSEQ6 - Fun with Sequences (Act 4) │ └── Fun with Sequences (Act 4).R ├── SMPSEQ7 - Fun with Sequences (Act 5) │ └── Fun with Sequences (Act 5).R ├── SMPSEQ8 - Fun with Sequences (Act 6) │ └── Fun with Sequences (Act 6).R ├── SMPSEQ9 - Fun with Sequences (Act 7) │ └── Fun with Sequences (Act 7).R ├── SMPSUM - Iterated sums │ └── Iterated sums.R ├── SMPWOW - Wow │ └── Wow.sh ├── SOD - Sum of Divisors │ └── Sum of Divisors.py ├── SPCQ - Gopu and Digits Divisibility │ └── SPCQ.java ├── SPCS - Gopu And Palindromes │ └── SPCS.java ├── SPTTRN1 - Straight Line Spiral Pattern (Act 1) │ └── SPTTRN1.java ├── SPTTRN2 - Straight Line Spiral Pattern (Act 2) │ └── SPTTRN2.java ├── SPTTRN3 - Straight Line Spiral Pattern (Act 3) │ └── SPTTRN3.java ├── SPTTRN4 - Straight Line Spiral Pattern (Act 4) │ └── SPTTRN4.java ├── SSORT - Silly Sort │ └── SSORT.java ├── STACKEZ - Easy Stack │ └── STACKEZ.java ├── STRHH - Half of the half │ └── STRHH - Half of the half.py ├── STRONGN - Strong Number │ └── STRONGN.java ├── SUCCESS - Success │ ├── Success.c │ └── Success_v2.c ├── SUMFOUR - 4 values whose sum is 0 │ └── SUMFOUR.java ├── SUMITR - Sums in a Triangle │ └── Sums in a Triangle.py ├── SUMLIS - Somma i numeri │ └── Somma i numeri.py ├── SUMSCALC - Sums to calculate │ └── SUMSCALC.java ├── SUMTRIAN - Sums in a Triangle (tutorial) │ └── Sums in a Triangle (tutorial).py ├── SUMUNZ - Sum Until 0 │ └── Sum Until 0.py ├── TAP2015H - Hugo s homework │ └── Hugo s homework.py ├── TAP2016A - Helping grandpa Laino │ └── Helping grandpa Laino.sh ├── TDPRIMES - Printing some primes │ ├── TDPRIMES.java │ ├── TDPRIMES2.java │ └── TDPRIMES3.java ├── TESTINT_Test 1 │ └── Test 1.sh ├── TEST_Life, the Universe, and Everything │ ├── 1_Life, the Universe, and Everything.R │ ├── 1_Life, the Universe, and Everything.py │ ├── 1_Life, the Universe, and Everything.sh │ └── TEST.java ├── THINK - Strange Pattern (Easy) │ └── Strange Pattern (Easy).cpp ├── THINKBIT - Strange Pattern (Medium) │ └── Strange Pattern (Medium).cpp ├── THINKX - Strange Pattern (Hard) │ └── Strange Pattern (Hard).cpp ├── THREENUMBERS - nth number │ └── nth number.py ├── TMUL - Not So Fast Multiplication │ └── Not So Fast Multiplication.py ├── TRIALDIV - Trial Division │ └── TRIALDIV.java ├── TRICOUNT_Counting Triangles │ └── TRICOUNT.java ├── TRIGALGE_Easy Calculation │ └── Easy Calculation.py ├── TRI_SUMS - Sums in a triangle │ └── TRI_SUMS.py ├── TSHOW1 - Amusing numbers │ └── Amusing numbers.py ├── TSMIVIOLET - Violet and Her Dream Land │ └── Violet and Her Dream Land.sh ├── TSORT - Turbo Sort │ └── TSORT.java ├── TTREAT - Happy Telephones │ └── TTREAT.java ├── UCV2013I_Tambourine │ └── Tambourine.R ├── UFPR14D_Inquire │ └── UFPR14D.java ├── VECTAR11_Game of Squares │ └── VECTAR11.java ├── VFMUL - Very Fast Multiplication │ └── VFMUL.java ├── VLN - Vải Lục Ngạn │ └── Vải Lục Ngạn.py ├── VPL0_E - External Sequence │ ├── External Sequence.py │ └── External Sequence_v2.py ├── WILLITST - Will it ever stop │ └── Will it ever stop.py ├── WORDCNT - Word Counting │ └── Word Counting.py ├── WORKB - Working in Beijing │ └── WORKB.java ├── WPC4C - Shortcut │ └── WPC4C.java ├── YODANESS - Yodaness Level │ └── YODANESS.java └── ZCR - Zen And His Crush │ └── ZCR.java └── create readme.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.Rhistory 2 | *.class 3 | *.RData 4 | *.vscode 5 | **/.ipynb_checkpoints 6 | Kaggle/*/input/ 7 | Kaggle/*/test/ 8 | Kaggle/*/output/ 9 | **/__*/ 10 | -------------------------------------------------------------------------------- /CodeChef/TEST - Life, the Universe, and Everything/1_Life, the Universe, and Everything.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: TEST - Life, the Universe, and Everything 2 | # Link : https://www.codechef.com/problems/TEST 3 | # Author : Wojciech Raszka 4 | # E-mail : contact@gitpistachio 5 | # Date created : 2019-11-08 6 | # Description : 7 | # Status : Accepted (33377910) 8 | # Tags : python 9 | # Comment : 10 | 11 | while True: 12 | ans = input() 13 | if ans == '42': 14 | break 15 | print(ans) 16 | -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/CONTAIN - The Delicious Cake/samples/input1.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 8 1 3 | 0 0 4 | 1 0 5 | 2 0 6 | 3 0 7 | 2 5 8 | 5 0 9 | 4 0 10 | 7 0 11 | 2 3 12 | 6 4 13 | 0 0 14 | 12 0 15 | 6 10 16 | 4 2 17 | 8 2 18 | 6 9 19 | 4 1 20 | 6 9 21 | 6 10 22 | 6 3 23 | 1 1 24 | 1 1 25 | 2 2 26 | 3 7 27 | -1 -1 28 | 3 -1 29 | 3 3 30 | -1 -1 31 | 3 -1 32 | 3 3 33 | 0 -1 34 | 1 1 35 | 2 1 36 | 4 4 37 | 5 12 38 | 0 2 39 | 0 5 40 | 5 0 41 | 5 5 42 | 0 0 43 | 0 4 44 | 0 5 45 | 5 0 46 | 3 0 47 | 5 3 48 | 5 5 49 | 2 5 50 | 2 2 51 | 0 6 52 | -1 0 53 | 7 0 54 | 5 10 -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/CONTAIN - The Delicious Cake/samples/input2.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 6 2 3 | 0 0 4 | 6 0 5 | 3 4 6 | 2 1 7 | 4 1 8 | 3 3 9 | 6 6 10 | 3 3 -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/CONTAIN - The Delicious Cake/samples/output1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 1 4 | 0 5 | 2 6 | 0 7 | 0 8 | 0 9 | 0 10 | 0 11 | 0 12 | 1 13 | 0 14 | 0 15 | 0 16 | 0 17 | 0 18 | 0 19 | 0 20 | 0 21 | 1 22 | 0 23 | 0 24 | 0 25 | 0 -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/CONTAIN - The Delicious Cake/samples/output2.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/EOEO - The Tom and Jerry Game!/The Tom and Jerry Game!.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: EOEO - The Tom and Jerry Game! 2 | # Link : https://www.codechef.com/JUNE20B/problems/EOEO 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.site 6 | # Date created : 2020-06-05 7 | # Description : 8 | # Status : Accepted (33719502) 9 | # Tags : python, game theory 10 | # Comment : 100 11 | 12 | from sys import stdin, stdout 13 | 14 | 15 | def solve(ts): 16 | while ts & 1 == 0: 17 | ts >>= 1 18 | 19 | return ts//2 20 | 21 | 22 | no_of_test_cases = int(stdin.readline()) 23 | for _ in range(no_of_test_cases): 24 | ts = int(stdin.readline()) 25 | no_of_possible_js = solve(ts) 26 | stdout.write(str(no_of_possible_js) + "\n") 27 | -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/GUESSG - Guessing Game/__pycache__/segment.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitPistachio/Competitive-programming/f8a73f5152b2016b1603a64b7037602d2ab2c06e/Contests/JUNE20B - June Challenge 2020 Division 2/GUESSG - Guessing Game/__pycache__/segment.cpython-38.pyc -------------------------------------------------------------------------------- /Contests/JUNE20B - June Challenge 2020 Division 2/PRICECON - Chef and Price Control/Chef and Price Control.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: PRICECON - Chef and Price Control 2 | # Link : https://www.codechef.com/JUNE20B/problems/PRICECON 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.site 6 | # Date created : 2020-06-05 7 | # Description : 8 | # Status : Accepted (33700367) 9 | # Tags : python 10 | # Comment : 100 11 | 12 | from sys import stdin, stdout 13 | 14 | no_of_test_cases = int(stdin.readline()) 15 | 16 | for _ in range(no_of_test_cases): 17 | no_of_items, max_price = map(int, stdin.readline().split()) 18 | max_revenue = sum(map(lambda x: int(x) - min(max_price, int(x)), stdin.readline().split())) 19 | stdout.write(str(max_revenue) + "\n") 20 | -------------------------------------------------------------------------------- /Contests/LEARNDSA - DSA Learning Series/Contest 1/FCTRL - Factorial/Factorial.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: FCTRL - Factorial 2 | # Link : https://www.codechef.com/LRNDSA01/problems/FCTRL 3 | # Author : Wojciech Raszka 4 | # E-mail : contact@gitpistachio.com 5 | # Date created : 2020-05-31 6 | # Description : 7 | # Status : Accepted (33527157) 8 | # Tags : python, number of trailing zeros in n!, integer sequence A027868 (OEIS), factorial 9 | # Comment : 10 | 11 | def Z(n): 12 | d = 5 13 | no_of_zeros = 0 14 | while d <= n: 15 | no_of_zeros += n//d 16 | d *= 5 17 | 18 | return no_of_zeros 19 | 20 | T = int(input()) 21 | N = [int(input()) for i in range(T)] 22 | 23 | for n in N: 24 | print(Z(n)) 25 | -------------------------------------------------------------------------------- /Contests/LEARNDSA - DSA Learning Series/Contest 1/FLOW007 - Reverse The Number/Reverse The Number.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: FLOW007 - Reverse The Number 2 | # Link : https://www.codechef.com/LRNDSA01/problems/FLOW007 3 | # Author : Wojciech Raszka 4 | # E-mail : contact@gitpistachio 5 | # Date created : 2020-05-31 6 | # Description : 7 | # Status : Accepted (33527003) 8 | # Tags : python 9 | # Comment : 10 | 11 | from sys import stdin, stdout 12 | 13 | no_of_test_cases = int(stdin.readline()) 14 | 15 | for _ in range(no_of_test_cases): 16 | n = int(stdin.readline().strip()[::-1]) 17 | stdout.write("{}\n".format(n)) 18 | -------------------------------------------------------------------------------- /Contests/LEARNDSA - DSA Learning Series/Contest 1/TEST - Life, the Universe, and Everything/Life, the Universe, and Everything.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: TEST - Life, the Universe, and Everything 2 | # Link : https://www.codechef.com/LRNDSA01/problems/TEST 3 | # Author : Wojciech Raszka 4 | # E-mail : contact@gitpistachio 5 | # Date created : 2020-05-31 6 | # Description : 7 | # Status : Accepted (33526794) 8 | # Tags : python 9 | # Comment : 10 | 11 | while True: 12 | ans = input() 13 | if ans == '42': 14 | break 15 | print(ans) 16 | -------------------------------------------------------------------------------- /Contests/LTIME84B - May Lunchtime 2020 Division 2/LOSTWKND - Lost Weekends/Lost Weekends.py: -------------------------------------------------------------------------------- 1 | # Project name : CodeChef: LOSTWKND - Lost Weekends 2 | # Link : https://www.codechef.com/LTIME84B/problems/LOSTWKND 3 | # Try it on : https://ideone.com/mtLUBm 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.site 6 | # Date created : 2020-05-30 7 | # Description : 8 | # Status : Accepted(33452042) 9 | # Tags : python 10 | # Comment : 100 11 | 12 | from sys import stdin, stdout 13 | 14 | no_of_test_cases = int(stdin.readline()) 15 | 16 | for _ in range(no_of_test_cases): 17 | A1, A2, A3, A4, A5, P = map(int, stdin.readline().split()) 18 | if P*(A1 + A2 + A3 + A4 + A5) > 120: 19 | stdout.write("Yes\n") 20 | else: 21 | stdout.write("No\n") 22 | -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 0 Hello, World/30 Hello, World.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 0: Hello, World 2 | # Link : https://www.hackerrank.com/challenges/30-hello-world/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-18 7 | # Description : 8 | # Status : Accepted (164610037) 9 | # Tags : python 10 | # Comment : 11 | 12 | 13 | input_string = input() 14 | 15 | print('Hello, World.') 16 | print(input_string) 17 | -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 1 Data Types/Data Types.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 1: Data Types 2 | # Link : https://www.hackerrank.com/challenges/30-data-types/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-19 7 | # Description : 8 | # Status : Accepted (164758042) 9 | # Tags : python 10 | # Comment : 11 | 12 | i = 4 13 | d = 4.0 14 | s = 'HackerRank ' 15 | 16 | my_i = int(input()) 17 | my_d = float(input()) 18 | my_s = input() 19 | 20 | print(i + my_i) 21 | print('{:.1f}'.format(d + my_d)) 22 | print(s + my_s) 23 | -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 14 Scope/Scope.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 14: Scope 2 | # Link : https://www.hackerrank.com/challenges/30-scope/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-03 7 | # Description : 8 | # Status : Accepted (167017112) 9 | # Tags : python 10 | # Comment : 11 | 12 | class Difference: 13 | def __init__(self, a): 14 | self.__elements = a 15 | 16 | def computeDifference(self): 17 | self.maximumDifference = max(a) - min(a) 18 | 19 | # End of Difference class 20 | 21 | _ = input() 22 | a = [int(e) for e in input().split(' ')] 23 | 24 | d = Difference(a) 25 | d.computeDifference() 26 | 27 | print(d.maximumDifference) -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 16 Exceptions - String to Integer/Exceptions - String to Integer.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 16: Exceptions - String to Integer 2 | # Link : https://www.hackerrank.com/challenges/30-exceptions-string-to-integer/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-10 7 | # Description : 8 | # Status : Accepted (168231188) 9 | # Tags : python 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import sys 15 | 16 | 17 | S = input().strip() 18 | 19 | try: 20 | val = int(S) 21 | print(val) 22 | except ValueError: 23 | print('Bad String') 24 | -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 5 Loops/Loops.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 5: Loops 2 | # Link : https://www.hackerrank.com/challenges/30-loops/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-23 7 | # Description : 8 | # Status : Accepted (165429904) 9 | # Tags : python 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import math 15 | import os 16 | import random 17 | import re 18 | import sys 19 | 20 | 21 | 22 | if __name__ == '__main__': 23 | n = int(input()) 24 | 25 | for i in range(1, 11): 26 | print('{} x {} = {}'.format(n, i, n*i)) -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 6 Let's Review/Let's Review.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 6: Let's Review 2 | # Link : https://www.hackerrank.com/challenges/30-review-loop/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-25 7 | # Description : 8 | # Status : Accepted (165648152) 9 | # Tags : python 10 | # Comment : 11 | 12 | no_of_test_cases = int(input()) 13 | 14 | for _ in range(no_of_test_cases): 15 | text = input().rstrip() 16 | n = len(text) 17 | odd = text[1:n:2] 18 | even = text[0:n:2] 19 | print(even, odd) -------------------------------------------------------------------------------- /HackerRank/30 Days of Code/Day 7 Arrays/Arrays.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Day 7: Arrays 2 | # Link : https://www.hackerrank.com/challenges/30-arrays/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-25 7 | # Description : 8 | # Status : Accepted (165778594) 9 | # Tags : python 10 | # Comment : 11 | 12 | import math 13 | import os 14 | import random 15 | import re 16 | import sys 17 | 18 | 19 | 20 | if __name__ == '__main__': 21 | n = int(input()) 22 | 23 | arr = list(map(int, input().rstrip().split())) 24 | print(' '.join(map(str, arr[::-1]))) -------------------------------------------------------------------------------- /HackerRank/African Cities/African Cities.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: African Cities 3 | * Link : https://www.hackerrank.com/challenges/african-cities/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209568607) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select 15 | ct.name 16 | from CITY ct 17 | inner join COUNTRY cn on cn.code = ct.countrycode 18 | where cn.continent = 'Africa'; -------------------------------------------------------------------------------- /HackerRank/Arithmetic Operators/Arithmetic Operators.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Arithmetic Operators 2 | # Link : https://www.hackerrank.com/challenges/python-arithmetic-operators/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169094759) 9 | # Tags : python 10 | # Comment : 11 | 12 | if __name__ == '__main__': 13 | a = int(input()) 14 | b = int(input()) 15 | print(a + b) 16 | print(a - b) 17 | print(a*b) -------------------------------------------------------------------------------- /HackerRank/Average Population of Each Continent/Average Population of Each Continent.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Average Population of Each Continent 3 | * Link : https://www.hackerrank.com/challenges/average-population-of-each-continent/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209569247) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select 15 | cn.continent 16 | , floor(avg(ct.population)) avg_city_population 17 | from city ct 18 | inner join country cn on cn.code = ct.countrycode 19 | group by cn.continent; -------------------------------------------------------------------------------- /HackerRank/Average Population/Average Population.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Average Population 3 | * Link : https://www.hackerrank.com/challenges/average-population/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209731458) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select floor(avg(population)) 15 | from city; -------------------------------------------------------------------------------- /HackerRank/Binary Tree Nodes/Binary Tree Nodes.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Binary Tree Nodes 3 | * Link : https://www.hackerrank.com/challenges/binary-search-tree-1/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210122016) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select 15 | b.n 16 | , case 17 | when b.p is null then 'Root' 18 | when exists (select * from BST c where c.p = b.n) then 'Inner' 19 | else 'Leaf' 20 | end 21 | from BST b 22 | order by b.n; -------------------------------------------------------------------------------- /HackerRank/Calendar Module/Calendar Module.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Calendar Module 2 | # Link : https://www.hackerrank.com/challenges/calendar-module/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-17 7 | # Description : 8 | # Status : Accepted (209230395) 9 | # Tags : python 10 | # Comment : 11 | 12 | import calendar 13 | 14 | calendar.setfirstweekday(calendar.MONDAY) 15 | 16 | month, day, year = map(int, input().split()) 17 | 18 | print(list(calendar.day_name)[calendar.weekday(year, month, day)].upper()) 19 | -------------------------------------------------------------------------------- /HackerRank/Capitalize!/Capitalize!.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Capitalize! 2 | # Link : https://www.hackerrank.com/challenges/capitalize/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169244429) 9 | # Tags : python 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import math 15 | import os 16 | import random 17 | import re 18 | import sys 19 | 20 | # Complete the solve function below. 21 | def solve(s): 22 | return ' '.join(map(lambda x: x.capitalize(), s.split(' '))) 23 | 24 | if __name__ == '__main__': 25 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 26 | 27 | s = input() 28 | 29 | result = solve(s) 30 | 31 | fptr.write(result + '\n') 32 | 33 | fptr.close() 34 | -------------------------------------------------------------------------------- /HackerRank/Collections.OrderedDict()/Collections.OrderedDict().py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Collections.OrderedDict() 2 | # Link : https://www.hackerrank.com/challenges/py-collections-ordereddict/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-19 7 | # Description : 8 | # Status : Accepted (209533950) 9 | # Tags : python 10 | # Comment : 11 | 12 | from collections import OrderedDict 13 | 14 | no_of_items = int(input()) 15 | 16 | bought_items = OrderedDict() 17 | for _ in range(no_of_items): 18 | item_name, price = input().rstrip().rsplit(' ', 1) 19 | bought_items[item_name] = bought_items.get(item_name, 0) + int(price) 20 | 21 | for item_name, net_price in bought_items.items(): 22 | print(item_name, net_price) 23 | -------------------------------------------------------------------------------- /HackerRank/Collections.namedtuple()/Collections.namedtuple().py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Collections.namedtuple() 2 | # Link : ttps://www.hackerrank.com/challenges/py-collections-namedtuple/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-17 7 | # Description : 8 | # Status : Accepted (209228117) 9 | # Tags : python 10 | # Comment : 11 | 12 | from collections import namedtuple 13 | 14 | no_of_sudents = int(input()) 15 | 16 | 17 | field_names = input() 18 | Mark = namedtuple('Mark',field_names) 19 | 20 | sum_of_marks = 0 21 | for _ in range(no_of_sudents): 22 | mark = Mark(*(input().split())) 23 | sum_of_marks += int(mark.MARKS) 24 | 25 | print(sum_of_marks/no_of_sudents) 26 | -------------------------------------------------------------------------------- /HackerRank/Company Logo/Company Logo.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Company Logo 2 | # Link : https://www.hackerrank.com/challenges/most-commons/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-18 7 | # Description : 8 | # Status : Accepted (209380806) 9 | # Tags : python 10 | # Comment : 11 | 12 | from collections import Counter 13 | 14 | if __name__ == '__main__': 15 | s = input() 16 | c = Counter(s) 17 | for letter, count in sorted(c.items(), key=lambda pair: (-pair[1], pair[0]))[:3]: 18 | print(letter, count) 19 | -------------------------------------------------------------------------------- /HackerRank/Compress the String!/Compress the String!.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Compress the String! 2 | # Link : https://www.hackerrank.com/challenges/compress-the-string/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-16 7 | # Description : 8 | # Status : Accepted (209083008) 9 | # Tags : python 10 | # Comment : 11 | 12 | from itertools import groupby 13 | 14 | S = input() 15 | 16 | groups = [] 17 | for key, group in groupby(S): 18 | groups.append('({}, {})'.format(len(list(group)), key)) 19 | 20 | print(' '.join(groups)) 21 | -------------------------------------------------------------------------------- /HackerRank/Contest Leaderboard/Contest Leaderboard.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Contest Leaderboard 3 | * Link : https://www.hackerrank.com/challenges/contest-leaderboard/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210131493) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select h.hacker_id, h.name, sum(s.best_score) total_score 15 | from Hackers h 16 | inner join 17 | ( 18 | select hacker_id, max(score) best_score 19 | from Submissions 20 | group by hacker_id, challenge_id 21 | ) s on s.hacker_id = h.hacker_id 22 | group by h.hacker_id, h.name 23 | having sum(s.best_score) > 0 24 | order by total_score desc, h.hacker_id; -------------------------------------------------------------------------------- /HackerRank/DefaultDict Tutorial/DefaultDict Tutorial.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: DefaultDict Tutorial 2 | # Link : https://www.hackerrank.com/challenges/defaultdict-tutorial/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-17 7 | # Description : 8 | # Status : Accepted (209190401) 9 | # Tags : python 10 | # Comment : 11 | 12 | from collections import defaultdict 13 | 14 | n, m = map(int, input().split()) 15 | 16 | A = defaultdict(list) 17 | for i in range(n): 18 | A[input()].append(str(i + 1)) 19 | 20 | for _ in range(m): 21 | b = input() 22 | if b in A: 23 | print(' '.join(A[b])) 24 | else: 25 | print('-1') 26 | -------------------------------------------------------------------------------- /HackerRank/Designer Door Mat/Designer Door Mat.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: String Formatting 2 | # Link : https://www.hackerrank.com/challenges/python-string-formatting/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169233941) 9 | # Tags : python 10 | # Comment : 11 | 12 | n, m = map(int, input().split()) 13 | 14 | for i in range(n//2): 15 | print(('.|.'*(2*i + 1)).center(m, '-')) 16 | 17 | print('WELCOME'.center(m, '-')) 18 | 19 | for i in range(n//2 - 1, -1, -1): 20 | print(('.|.'*(2*i + 1)).center(m, '-')) 21 | -------------------------------------------------------------------------------- /HackerRank/Draw The Triangle 1/Draw The Triangle 1.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Draw The Triangle 1 3 | * Link : https://www.hackerrank.com/challenges/draw-the-triangle-1/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209729820) 10 | * Tags : sql, drawing of a triangle 11 | * Comment : 12 | */ 13 | 14 | select rpad('*', 41 - level*2, ' *') 15 | from dual 16 | connect by level <= 20; -------------------------------------------------------------------------------- /HackerRank/Draw The Triangle 2/Draw The Triangle 2.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Draw The Triangle 2 3 | * Link : https://www.hackerrank.com/challenges/draw-the-triangle-2/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209730026) 10 | * Tags : sql, drawing of a triangle 11 | * Comment : 12 | */ 13 | 14 | select rpad('*', level*2, ' *') 15 | from dual 16 | connect by level <= 20; -------------------------------------------------------------------------------- /HackerRank/Employee Names/Employee Names.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Employee Names 3 | * Link : https://www.hackerrank.com/challenges/name-of-employees/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209568029) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select name 15 | from EMPLOYEE 16 | order by 1; -------------------------------------------------------------------------------- /HackerRank/Employee Salaries/Employee Salaries.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Employee Salaries 3 | * Link : https://www.hackerrank.com/challenges/salary-of-employees/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209568295) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select 15 | name 16 | from EMPLOYEE 17 | where salary > 2000 18 | and months < 10 19 | order by employee_id; -------------------------------------------------------------------------------- /HackerRank/Find Angle MBC/Find Angle MBC.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Find Angle MBC 2 | # Link : https://www.hackerrank.com/challenges/find-angle/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-16 7 | # Description : 8 | # Status : Accepted (209089726) 9 | # Tags : python, math, geometry, right triangle, Thales's theorem, trigonometry 10 | # Comment : 11 | 12 | from math import atan, pi 13 | 14 | AB = float(input()) 15 | BC = float(input()) 16 | 17 | print('{}\u00B0'.format(round(atan(AB/BC)*180/pi))) 18 | -------------------------------------------------------------------------------- /HackerRank/Finding the percentage/Finding the percentage.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Finding the percentage 2 | # Link : https://www.hackerrank.com/challenges/finding-the-percentage/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169103368) 9 | # Tags : python 10 | # Comment : 11 | 12 | if __name__ == '__main__': 13 | n = int(input()) 14 | student_marks = {} 15 | for _ in range(n): 16 | name, *line = input().split() 17 | scores = list(map(float, line)) 18 | student_marks[name] = scores 19 | query_name = input() 20 | 21 | marks = student_marks[query_name] 22 | print('{:.2f}'.format(sum(marks)/len(marks))) 23 | -------------------------------------------------------------------------------- /HackerRank/Gemstones/Gemstones.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Gemstones 2 | # Link : https://www.hackerrank.com/challenges/gem-stones/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-19 7 | # Description : 8 | # Status : Accepted (209531287) 9 | # Tags : python 10 | # Comment : 11 | 12 | from string import ascii_lowercase 13 | 14 | n = int(input()) 15 | 16 | gemstones = set(ascii_lowercase) 17 | for _ in range(n): 18 | s = input().rstrip() 19 | for gemstone in gemstones.copy(): 20 | if gemstone not in s: 21 | gemstones.remove(gemstone) 22 | 23 | print(len(gemstones)) 24 | -------------------------------------------------------------------------------- /HackerRank/Higher Than 75 Marks/Higher Than 75 Marks.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Higher Than 75 Marks 3 | * Link : https://www.hackerrank.com/challenges/more-than-75-marks/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209567823) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select 15 | name 16 | from STUDENTS 17 | where marks > 75 18 | order by substr(name, length(name) - 2, 3), id; -------------------------------------------------------------------------------- /HackerRank/Japan Population/Japan Population.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Japan Population 3 | * Link : https://www.hackerrank.com/challenges/japan-population/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209731629) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select sum(population) 15 | from city 16 | where countrycode = 'JPN'; -------------------------------------------------------------------------------- /HackerRank/Japanese Cities' Attributes/Japanese Cities' Attributes.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Japanese Cities' Attributes 3 | * Link : https://www.hackerrank.com/challenges/japanese-cities-attributes/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209550335) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select * 15 | from CITY 16 | where countrycode = 'JPN'; -------------------------------------------------------------------------------- /HackerRank/Japanese Cities' Names/Japanese Cities' Names.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Japanese Cities' Names 3 | * Link : https://www.hackerrank.com/challenges/japanese-cities-name/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209550546) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select name 15 | from CITY 16 | where countrycode = 'JPN'; -------------------------------------------------------------------------------- /HackerRank/List Comprehensions/List Comprehensions.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: List Comprehensions 2 | # Link : https://www.hackerrank.com/challenges/list-comprehensions/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169100749) 9 | # Tags : python 10 | # Comment : 11 | 12 | 13 | if __name__ == '__main__': 14 | x = int(input()) 15 | y = int(input()) 16 | z = int(input()) 17 | n = int(input()) 18 | 19 | points = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1)] 20 | 21 | points = list(filter(lambda p: sum(p) != n, points)) 22 | print(points) 23 | -------------------------------------------------------------------------------- /HackerRank/Loops/Loops.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Loops 2 | # Link : https://www.hackerrank.com/challenges/python-loops/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169095306) 9 | # Tags : python 10 | # Comment : 11 | 12 | if __name__ == '__main__': 13 | n = int(input()) 14 | 15 | for i in range(n): 16 | print(i*i) 17 | -------------------------------------------------------------------------------- /HackerRank/Maximize It!/Maximize It!.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Maximize It! 2 | # Link : https://www.hackerrank.com/challenges/maximize-it/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-18 7 | # Description : 8 | # Status : Accepted (209376068) 9 | # Tags : python 10 | # Comment : 11 | 12 | from itertools import product 13 | 14 | K, M = map(int, input().split()) 15 | 16 | A = [] 17 | for _ in range(K): 18 | A.append(map(int, input().split()[1:])) 19 | 20 | max_s = 0 21 | for p in product(*A): 22 | s = sum(map(lambda x: x*x, p)) % M 23 | if s > max_s: 24 | max_s = s 25 | 26 | print(max_s) 27 | -------------------------------------------------------------------------------- /HackerRank/Mod Divmod/Mod Divmod.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Mod Divmod 2 | # Link : https://www.hackerrank.com/challenges/python-mod-divmod/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-17 7 | # Description : 8 | # Status : Accepted (209226305) 9 | # Tags : python 10 | # Comment : 11 | 12 | a = int(input()) 13 | b = int(input()) 14 | 15 | print(a//b) 16 | print(a % b) 17 | print(divmod(a, b)) 18 | -------------------------------------------------------------------------------- /HackerRank/Mutations/Mutations.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Mutations 2 | # Link : https://www.hackerrank.com/challenges/python-mutations/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169214742) 9 | # Tags : python 10 | # Comment : 11 | 12 | def mutate_string(string, position, character): 13 | l = list(string) 14 | l[position] = character 15 | return ''.join(l) 16 | 17 | if __name__ == '__main__': 18 | s = input() 19 | i, c = input().split() 20 | s_new = mutate_string(s, int(i), c) 21 | print(s_new) -------------------------------------------------------------------------------- /HackerRank/Occupations/Occupations.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Occupations 3 | * Link : https://www.hackerrank.com/challenges/occupations/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210119565) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select doctor, professor, singer, actor 15 | from 16 | ( 17 | select 18 | name 19 | , occupation 20 | , row_number() over (partition by occupation order by name) position 21 | from occupations 22 | ) 23 | pivot 24 | ( 25 | min(name) 26 | for occupation in ('Doctor' doctor, 'Professor' professor, 'Singer' singer, 'Actor' actor) 27 | ) 28 | order by doctor, professor, singer, actor; -------------------------------------------------------------------------------- /HackerRank/Placements/Placements.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Placements 3 | * Link : https://www.hackerrank.com/challenges/placements/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210142067) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select s.name 15 | from Students s 16 | inner join Friends f on f.ID = s.ID 17 | inner join Packages sp on sp.ID = s.ID 18 | inner join Packages fp on fp.ID = f.FRIEND_ID 19 | where fp.SALARY > sp.SALARY 20 | order by fp.SALARY; -------------------------------------------------------------------------------- /HackerRank/Polar Coordinates/Polar Coordinates.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Polar Coordinates 2 | # Link : https://www.hackerrank.com/challenges/polar-coordinates/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-10-04 7 | # Description : 8 | # Status : Accepted (182525196) 9 | # Tags : python 10 | # Comment : 11 | 12 | import cmath 13 | 14 | c = complex(input()) 15 | 16 | print(abs(c)) 17 | print(cmath.phase(c)) 18 | -------------------------------------------------------------------------------- /HackerRank/Population Census/Population Census.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Population Census 3 | * Link : https://www.hackerrank.com/challenges/asian-population/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209730736) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select sum(ct.population) 15 | from city ct 16 | inner join country cn on cn.code = ct.countrycode 17 | where cn.continent = 'Asia'; -------------------------------------------------------------------------------- /HackerRank/Population Density Difference/Population Density Difference.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Population Density Difference 3 | * Link : https://www.hackerrank.com/challenges/population-density-difference/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209731850) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select max(population) - min(population) 15 | from city; -------------------------------------------------------------------------------- /HackerRank/Print Function/Print Function.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Print Function 2 | # Link : https://www.hackerrank.com/challenges/python-print/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169096236) 9 | # Tags : python 10 | # Comment : 11 | 12 | if __name__ == '__main__': 13 | n = int(input()) 14 | for i in range(1, n + 1): 15 | print(i, end='') 16 | 17 | print('') 18 | -------------------------------------------------------------------------------- /HackerRank/Python Division/Python Division.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Python: Division 2 | # Link : https://www.hackerrank.com/challenges/python-division/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169094929) 9 | # Tags : python 10 | # Comment : 11 | 12 | if __name__ == '__main__': 13 | a = int(input()) 14 | b = int(input()) 15 | print(a//b) 16 | print(a/b) 17 | -------------------------------------------------------------------------------- /HackerRank/Python If-Else/Python If-Else.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Python If-Else 2 | # Link : https://www.hackerrank.com/challenges/py-if-else/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169048802) 9 | # Tags : python 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import math 15 | import os 16 | import random 17 | import re 18 | import sys 19 | 20 | 21 | 22 | if __name__ == '__main__': 23 | n = int(input().strip()) 24 | 25 | if n & 1: 26 | print('Weird') 27 | elif n <= 5: 28 | print('Not Weird') 29 | elif n <= 20: 30 | print('Weird') 31 | else: 32 | print('Not Weird') 33 | 34 | -------------------------------------------------------------------------------- /HackerRank/Revising Aggregations - Averages/Revising Aggregations - Averages.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Revising Aggregations - Averages 3 | * Link : https://www.hackerrank.com/challenges/revising-aggregations-the-average-function/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209731322) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select avg(population) 15 | from city 16 | where district = 'California'; -------------------------------------------------------------------------------- /HackerRank/Revising Aggregations - The Count Function/Revising Aggregations - The Count Function.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Revising Aggregations - The Count Function 3 | * Link : https://www.hackerrank.com/challenges/revising-aggregations-the-count-function/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209731009) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select count(*) 15 | from city 16 | where population > 100000; -------------------------------------------------------------------------------- /HackerRank/Revising Aggregations - The Sum Function/Revising Aggregations - The Sum Function.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Revising Aggregations - The Sum Function 3 | * Link : https://www.hackerrank.com/challenges/revising-aggregations-sum/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209731179) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select sum(population) 15 | from city 16 | where district = 'California'; -------------------------------------------------------------------------------- /HackerRank/Revising the Select Query I/Revising the Select Query I.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Revising the Select Query I 3 | * Link : https://www.hackerrank.com/challenges/revising-the-select-query/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209549461) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select * 15 | from CITY 16 | where CountryCode = 'USA' 17 | and Population > 100000; -------------------------------------------------------------------------------- /HackerRank/Revising the Select Query II/Revising the Select Query II.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Revising the Select Query II 3 | * Link : https://www.hackerrank.com/challenges/revising-the-select-query-2/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209550105) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select NAME 15 | from CITY 16 | where countrycode = 'USA' 17 | and population > 120000; -------------------------------------------------------------------------------- /HackerRank/SQL Project Planning/SQL Project Planning.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: SQL Project Planning 3 | * Link : https://www.hackerrank.com/challenges/sql-projects/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210140868) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select min(start_date), max(end_date) 15 | from 16 | ( 17 | select d.*, sum(days_between_tasks) over (order by start_date) project 18 | from 19 | ( 20 | select p.* 21 | , start_date - NVL(lag(end_date, 1) over (order by p.start_date), start_date) days_between_tasks 22 | from Projects p 23 | ) d 24 | ) 25 | group by project 26 | order by count(*), 1; -------------------------------------------------------------------------------- /HackerRank/Say Hello, World! With Python/Say Hello, World! With Python.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Say "Hello, World!" With Python 2 | # Link : https://www.hackerrank.com/challenges/py-hello-world/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169047766) 9 | # Tags : python 10 | # Comment : 11 | 12 | print("Hello, World!") 13 | -------------------------------------------------------------------------------- /HackerRank/Select All/Select All.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Select All 3 | * Link : https://www.hackerrank.com/challenges/select-all-sql/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209535109) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select * 15 | from CITY -------------------------------------------------------------------------------- /HackerRank/Select By ID/Select By ID.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Select By ID 3 | * Link : https://www.hackerrank.com/challenges/select-by-id/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209549781) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select * 15 | from CITY 16 | where ID = 1661; -------------------------------------------------------------------------------- /HackerRank/Simple Array Sum/Simple Array Sum.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: The Tom and Jerry Game! 2 | # Link : https://www.hackerrank.com/challenges/simple-array-sum/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-18 7 | # Description : 8 | # Status : Accepted (164609180) 9 | # Tags : python 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import os 15 | import sys 16 | 17 | 18 | def simpleArraySum(ar): 19 | return sum(ar) 20 | 21 | 22 | if __name__ == '__main__': 23 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 24 | 25 | ar_count = int(input()) 26 | 27 | ar = list(map(int, input().rstrip().split())) 28 | 29 | result = simpleArraySum(ar) 30 | 31 | fptr.write(str(result) + '\n') 32 | 33 | fptr.close() 34 | -------------------------------------------------------------------------------- /HackerRank/Staircase/Staircase.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Staircase 2 | # Link : https://www.hackerrank.com/challenges/staircase/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-22 7 | # Description : 8 | # Status : Accepted (165255914) 9 | # Tags : python, console patters, staircase 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import math 15 | import os 16 | import random 17 | import re 18 | import sys 19 | 20 | # Complete the staircase function below. 21 | def staircase(n): 22 | for i in range(n): 23 | print(' '*(n - i - 1) + '#'*(i + 1)) 24 | 25 | if __name__ == '__main__': 26 | n = int(input()) 27 | 28 | staircase(n) 29 | -------------------------------------------------------------------------------- /HackerRank/String Formatting/String Formatting.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: String Formatting 2 | # Link : https://www.hackerrank.com/challenges/python-string-formatting/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169238377) 9 | # Tags : python 10 | # Comment : 11 | 12 | def print_formatted(number): 13 | s = len(bin(number)) - 2 14 | for i in range(1, number + 1): 15 | decimal = str(i) 16 | octal = oct(i)[2:] 17 | hexadecimal = hex(i)[2:].upper() 18 | binary = bin(i)[2:] 19 | 20 | print(decimal.rjust(s), octal.rjust(s), hexadecimal.rjust(s), binary.rjust(s)) 21 | 22 | if __name__ == '__main__': 23 | n = int(input()) 24 | print_formatted(n) -------------------------------------------------------------------------------- /HackerRank/String Split and Join/String Split and Join.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: String Split and Join 2 | # Link : https://www.hackerrank.com/challenges/python-string-split-and-join/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169213696) 9 | # Tags : python 10 | # Comment : 11 | 12 | def split_and_join(line): 13 | return '-'.join(line.split(' ')) 14 | 15 | if __name__ == '__main__': 16 | line = input() 17 | result = split_and_join(line) 18 | print(result) 19 | -------------------------------------------------------------------------------- /HackerRank/Symmetric Pairs/Symmetric Pairs.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Symmetric Pairs 3 | * Link : https://www.hackerrank.com/challenges/symmetric-pairs/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210143145) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | with FUNCTIONS_ as 15 | ( 16 | select row_number() over (order by X, Y) id, X, Y 17 | from Functions 18 | ) 19 | select distinct f.X, f.Y 20 | from FUNCTIONS_ f 21 | where f.X <= f.Y 22 | and exists (select * from FUNCTIONS_ sf where sf.Y = f.X and sf.X = f.Y and sf.id <> f.id) 23 | order by f.X; -------------------------------------------------------------------------------- /HackerRank/Text Wrap/Text Wrap.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Text Wrap 2 | # Link : https://www.hackerrank.com/challenges/text-wrap/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169232587) 9 | # Tags : python 10 | # Comment : 11 | 12 | import textwrap 13 | 14 | def wrap(string, max_width): 15 | return '\n'.join([string[i:i + max_width] for i in range(0, len(string), max_width)]) 16 | 17 | if __name__ == '__main__': 18 | string, max_width = input(), int(input()) 19 | result = wrap(string, max_width) 20 | print(result) -------------------------------------------------------------------------------- /HackerRank/The Blunder/The Blunder.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: The Blunder 3 | * Link : https://www.hackerrank.com/challenges/the-blunder/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-20 8 | * Description : 9 | * Status : Accepted (209732353) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select 15 | ceil(avg(salary) - avg(replace(salary, '0', ''))) 16 | from employees; -------------------------------------------------------------------------------- /HackerRank/The PADS/The PADS.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: The PADS 3 | * Link : https://www.hackerrank.com/challenges/the-pads/submissions/code/209839952 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209838956) 10 | * Tags : sql, manhattan distance 11 | * Comment : 12 | */ 13 | 14 | select name || '(' || substr(occupation, 1, 1) || ')' 15 | from OCCUPATIONS 16 | order by name; 17 | select 'There are a total of ' || count(*) || ' ' || lower(occupation) || 's.' 18 | from OCCUPATIONS 19 | group by occupation 20 | order by count(*), occupation; -------------------------------------------------------------------------------- /HackerRank/The Report/The Report.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: The Report 3 | * Link : https://www.hackerrank.com/challenges/the-report/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-22 8 | * Description : 9 | * Status : Accepted (209882377) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select case when g.grade >= 8 then s.name end, g.grade, s.marks 15 | from students s 16 | inner join grades g on s.marks between g.min_mark and g.max_mark 17 | order by g.grade desc, 1 nulls last; -------------------------------------------------------------------------------- /HackerRank/Time Conversion/Time Conversion.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Time Conversion 2 | # Link : https://www.hackerrank.com/challenges/time-conversion/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-06-23 7 | # Description : 8 | # Status : Accepted (165433031) 9 | # Tags : python, time conversion 10 | # Comment : 11 | 12 | #!/bin/python3 13 | 14 | import os 15 | import sys 16 | import time 17 | 18 | 19 | def timeConversion(s): 20 | v = time.strptime(s.rstrip(), '%I:%M:%S%p') 21 | return time.strftime('%H:%M:%S', v) 22 | 23 | if __name__ == '__main__': 24 | f = open(os.environ['OUTPUT_PATH'], 'w') 25 | 26 | s = input() 27 | 28 | result = timeConversion(s) 29 | 30 | f.write(result + '\n') 31 | 32 | f.close() 33 | -------------------------------------------------------------------------------- /HackerRank/Top Competitors/Top Competitors.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Top Competitors 3 | * Link : https://www.hackerrank.com/challenges/full-score/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-22 8 | * Description : 9 | * Status : Accepted (209979359) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select h.hacker_id, h.name 15 | from Hackers h 16 | inner join Submissions s on s.hacker_id = h.hacker_id 17 | inner join Challenges c on c.challenge_id = s.challenge_id 18 | inner join Difficulty d on d.difficulty_level = c.difficulty_level 19 | group by h.hacker_id, h.name 20 | having sum(case when s.score = d.score then 1 else 0 end) > 1 21 | order by sum(case when s.score = d.score then 1 else 0 end) desc, h.hacker_id; -------------------------------------------------------------------------------- /HackerRank/Top Earners/Top Earners.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Top Earners 3 | * Link : https://www.hackerrank.com/challenges/earnings-of-employees/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209831467) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select * 15 | from 16 | ( 17 | select salary*months, count(*) 18 | from employee 19 | group by salary*months 20 | order by 1 desc 21 | ) d 22 | where rownum <= 1; -------------------------------------------------------------------------------- /HackerRank/Triangle Quest 2/Triangle Quest 2.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Triangle Quest 2 2 | # Link : https://www.hackerrank.com/challenges/triangle-quest-2/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2021-04-17 7 | # Description : 8 | # Status : Accepted (209195163) 9 | # Tags : python, math, integer sequence A002275 (OEIS) 10 | # Comment : 11 | 12 | for i in range(1,int(input())+1): 13 | print(((10**i - 1)//9)**2) 14 | -------------------------------------------------------------------------------- /HackerRank/Tuples/Tuples.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Tuples 2 | # Link : https://www.hackerrank.com/challenges/python-tuples/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169212712) 9 | # Tags : python 10 | # Comment : 11 | 12 | if __name__ == '__main__': 13 | n = int(input()) 14 | integer_list = map(int, input().split()) 15 | 16 | print(hash(tuple(integer_list))) -------------------------------------------------------------------------------- /HackerRank/Type of Triangle/Type of Triangle.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Type of Triangle 3 | * Link : https://www.hackerrank.com/challenges/average-population-of-each-continent/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209571449) 10 | * Tags : sql, triangle 11 | * Comment : 12 | */ 13 | 14 | select 15 | case 16 | when a = b and b = c then 'Equilateral' 17 | when a + b <= c or a + c <= b or b + c <= a then 'Not A Triangle' 18 | when a = b or a = c or b = c then 'Isosceles' 19 | else 'Scalene' 20 | end 21 | from TRIANGLES; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 1/Weather Observation Station 1.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 1 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-1/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209550865) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select CITY, STATE 15 | from STATION; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 10/Weather Observation Station 10.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 10 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-10/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209566877) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, length(city), 1)) not in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 11/Weather Observation Station 11.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 11 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-11/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209567290) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, 1, 1)) not in ('a', 'e', 'i', 'o', 'u') 18 | or lower(substr(city, length(city), 1)) not in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 12/Weather Observation Station 12.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 12 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-12/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209567458) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, 1, 1)) not in ('a', 'e', 'i', 'o', 'u') 18 | and lower(substr(city, length(city), 1)) not in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 13/Weather Observation Station 13.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 13 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-13/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209832369) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select sum(lat_n) 15 | from station 16 | where lat_n > 38.7880 and lat_n < 137.2345; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 14/Weather Observation Station 14.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 14 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-14/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209832749) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select cast(max(lat_n) as decimal(20, 4)) 15 | from station 16 | where lat_n < 137.2345; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 15/Weather Observation Station 15.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 15 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-15/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209833244) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select round(long_w, 4) 15 | from station 16 | where lat_n = (select max(lat_n) from station where lat_n < 137.2345); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 16/Weather Observation Station 16.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 16 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-16/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209833520) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select round(min(lat_n), 4) 15 | from station 16 | where lat_n > 38.7780; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 17/Weather Observation Station 17.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 17 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-17/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209834058) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select round(long_w, 4) 15 | from station 16 | where lat_n = (select min(lat_n) from station where lat_n > 38.7780); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 18/Weather Observation Station 18.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 18 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-18/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209834626) 10 | * Tags : sql, manhattan distance 11 | * Comment : 12 | */ 13 | 14 | select round(max(lat_n) - min(lat_n) + max(long_w) - min(long_w), 4) 15 | from station; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 19/Weather Observation Station 19.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 19 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-19/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209838956) 10 | * Tags : sql, euclidean distance 11 | * Comment : 12 | */ 13 | 14 | select round(sqrt(power(min(lat_n) - max(lat_n), 2) + power(min(long_w) - max(long_w), 2)), 4) 15 | from station; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 2/Weather Observation Station 2.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 2 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-2/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-21 8 | * Description : 9 | * Status : Accepted (209831981) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select round(sum(lat_n), 2), round(sum(long_w), 2) 15 | from station; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 20/Weather Observation Station 20.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 20 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-20/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-23 8 | * Description : 9 | * Status : Accepted (210131955) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select round(median(lat_n), 4) 15 | from STATION; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 3/Weather Observation Station 3.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 3 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-3/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209551604) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | CITY 16 | from STATION 17 | where MOD(ID, 2) = 0; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 4/Weather Observation Station 4.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 4 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-4/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209551885) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select count(*) - count(distinct CITY) 15 | from STATION; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 5/Weather Observation Station 5.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 5 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-5/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209565450) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select * 15 | from 16 | ( 17 | select 18 | city, length(city) 19 | from STATION 20 | order by 2, 1 21 | ) d 22 | where rownum = 1 23 | union all 24 | select * 25 | from 26 | ( 27 | select 28 | city, length(city) 29 | from STATION 30 | order by 2 desc, 1 31 | ) d 32 | where rownum = 1; -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 6/Weather Observation Station 6.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 6 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-6/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209565912) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, 1, 1)) in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 7/Weather Observation Station 7.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 7 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-7/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209566382) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, length(city), 1)) in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 8/Weather Observation Station 8.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 8 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-8/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209566572) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, 1, 1)) in ('a', 'e', 'i', 'o', 'u') 18 | and lower(substr(city, length(city), 1)) in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/Weather Observation Station 9/Weather Observation Station 9.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : HackerRank: Weather Observation Station 9 3 | * Link : https://www.hackerrank.com/challenges/weather-observation-station-9/problem 4 | * Try it on : 5 | * Author : Wojciech Raszka 6 | * E-mail : contact@gitpistachio.com 7 | * Date created : 2021-04-19 8 | * Description : 9 | * Status : Accepted (209566735) 10 | * Tags : sql 11 | * Comment : 12 | */ 13 | 14 | select distinct 15 | city 16 | from STATION 17 | where lower(substr(city, 1, 1)) not in ('a', 'e', 'i', 'o', 'u'); -------------------------------------------------------------------------------- /HackerRank/What's Your Name/What's Your Name.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: What's Your Name? 2 | # Link : https://www.hackerrank.com/challenges/python-string-split-and-join/submissions/code/169213696 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169213696) 9 | # Tags : python 10 | # Comment : 11 | 12 | def print_full_name(a, b): 13 | print("Hello {} {}! You just delved into python.".format(a, b)) 14 | 15 | if __name__ == '__main__': 16 | first_name = input() 17 | last_name = input() 18 | print_full_name(first_name, last_name) 19 | -------------------------------------------------------------------------------- /HackerRank/Write a function/Write a function.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: Write a function 2 | # Link : https://www.hackerrank.com/challenges/write-a-function/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-15 7 | # Description : 8 | # Status : Accepted (169095879) 9 | # Tags : python 10 | # Comment : 11 | 12 | def is_leap(year): 13 | if year % 4: 14 | return False 15 | 16 | if year % 100 == 0 and year % 400: 17 | return False 18 | 19 | return True 20 | 21 | year = int(input()) 22 | print(is_leap(year)) 23 | -------------------------------------------------------------------------------- /HackerRank/itertools.combinations()/itertools.combinations().py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: itertools.combinations() 2 | # Link : https://www.hackerrank.com/challenges/itertools-combinations/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-10-02 7 | # Description : 8 | # Status : Accepted (182321738) 9 | # Tags : python 10 | # Comment : 11 | 12 | from itertools import combinations 13 | 14 | text, k = input().split() 15 | 16 | 17 | for r in range(1, int(k) + 1): 18 | cmbs = combinations(sorted(text), r=r) 19 | 20 | print(*list(map(lambda x: ''.join(x), cmbs)), sep="\n") 21 | -------------------------------------------------------------------------------- /HackerRank/itertools.combinations_with_replacement()/itertools.combinations_with_replacement().py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: itertools.combinations_with_replacement() 2 | # Link : https://www.hackerrank.com/challenges/itertools-combinations-with-replacement/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-10-03 7 | # Description : 8 | # Status : Accepted (182391730) 9 | # Tags : python 10 | # Comment : 11 | 12 | from itertools import combinations_with_replacement 13 | 14 | text, k = input().split() 15 | 16 | cmbs = combinations_with_replacement(sorted(text), r=int(k)) 17 | 18 | print(*list(map(lambda x: ''.join(x), cmbs)), sep="\n") 19 | -------------------------------------------------------------------------------- /HackerRank/itertools.permutations()/itertools.permutations().py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: itertools.permutations() 2 | # Link : https://www.hackerrank.com/challenges/itertools-permutations/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-10-02 7 | # Description : 8 | # Status : Accepted (182319358) 9 | # Tags : python 10 | # Comment : 11 | 12 | from itertools import permutations 13 | 14 | text, k = input().split() 15 | 16 | pmt = list(permutations(sorted(text), r=int(k))) 17 | 18 | 19 | print('\n'.join(map(lambda x: ''.join(x), pmt))) 20 | -------------------------------------------------------------------------------- /HackerRank/itertools.product()/itertools.product().py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: itertools.product() 2 | # Link : https://www.hackerrank.com/challenges/itertools-product/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-10-01 7 | # Description : 8 | # Status : Accepted (182148105) 9 | # Tags : python 10 | # Comment : 11 | 12 | from itertools import product 13 | 14 | A = map(int, input().split()) 15 | B = map(int, input().split()) 16 | 17 | AxB = list(product(A, B)) 18 | 19 | print(*AxB, sep=" ") 20 | -------------------------------------------------------------------------------- /HackerRank/sWAP cASE/sWAP cASE.py: -------------------------------------------------------------------------------- 1 | # Project name : HackerRank: sWAP cASE 2 | # Link : https://www.hackerrank.com/challenges/swap-case/problem 3 | # Try it on : 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 2020-07-16 7 | # Description : 8 | # Status : Accepted (169213416) 9 | # Tags : python 10 | # Comment : 11 | 12 | def swap_case(s): 13 | return s.swapcase() 14 | 15 | if __name__ == '__main__': 16 | s = input() 17 | result = swap_case(s) 18 | print(result) -------------------------------------------------------------------------------- /SPOJ/ACPC10A_What’s Next/ACPC10A.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: ACPC10A - What’s Next 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-02-10 5 | * Description : 6 | * Status : Accepted (23206155) 7 | * Comment : 8 | */ 9 | 10 | import java.util.Scanner; 11 | 12 | class ACPC10A{ 13 | public static void main(String args[]){ 14 | Scanner sc = new Scanner(System.in); 15 | int a, b, c; 16 | 17 | a = sc.nextInt(); 18 | b = sc.nextInt(); 19 | c = sc.nextInt(); 20 | while (a != 0 || b != 0 || c != 0){ 21 | if (b - a == c - b){ 22 | System.out.println("AP " + (c + b - a)); 23 | } else if (b*b == a*c) { 24 | System.out.println("GP " + (c*b/a)); 25 | } 26 | 27 | a = sc.nextInt(); 28 | b = sc.nextInt(); 29 | c = sc.nextInt(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SPOJ/ADDREV_Adding Reversed Numbers/42_Adding Reversed Numbers.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ADDREV - Adding reversed numbers 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-06 4 | # Description : 5 | # Status : Accepted (???) 6 | 7 | library('stringi') 8 | 9 | f <- file('stdin', open='r') 10 | 11 | no_of_cases <- as.integer(readLines(f, n=1)) 12 | 13 | for (i in 1:no_of_cases){ 14 | n <- as.integer(stri_reverse(as.character(sum(as.integer(stri_reverse(unlist(strsplit(readLines(f, n=1), ' ')))))))) 15 | write(n, stdout()) 16 | } 17 | -------------------------------------------------------------------------------- /SPOJ/ADDREV_Adding Reversed Numbers/42_Adding Reversed Numbers.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ADDREV - Adding Reversed Numbers 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-??-?? 5 | # Description : 6 | # Status : Accepted () 7 | # Tags : python 8 | # Comment : 9 | 10 | no_of_cases = int(input()) 11 | 12 | for c in range(no_of_cases): 13 | print(int(str(sum(map(lambda s: int(s[::-1]), input().split(' '))))[::-1])) 14 | -------------------------------------------------------------------------------- /SPOJ/ADDREV_Adding Reversed Numbers/42_Adding Reversed Numbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: ADDREV - Adding Reversed Numbers 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 7 | # Description : 8 | # Status : Time limit exceeded 9 | # Tags : bass 10 | # Comment : This is to slow for SPOJ but works on Ideone.com nicely. 11 | 12 | read no_of_cases 13 | 14 | for ((i=1; i<=$no_of_cases; i++)) 15 | do 16 | read pair_of_numbers 17 | 18 | z=$(echo $pair_of_numbers | rev) 19 | 20 | a=$(cut -d' ' -f1 <<< $z) 21 | b=$(cut -d' ' -f2 <<< $z) 22 | rs=$(echo $(($a+$b)) | rev) 23 | 24 | echo $rs | sed 's/^0*//' 25 | done 26 | -------------------------------------------------------------------------------- /SPOJ/ADV04J - Invisible point/Invisible point.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ADV04J - Invisible point 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-06-21 5 | # Description : 6 | # Status : Accepted (23956428) 7 | # Tags : python, length of binary representation, integer sequence A070941 (OEIS) 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | def lengthOfBinaryRepresentation(n): 13 | i = 0 14 | while n > 0: 15 | n = n >> 1 16 | i += 1 17 | 18 | return i 19 | 20 | T = int(stdin.readline()) 21 | 22 | stdout.write('\n'.join([str(lengthOfBinaryRepresentation(((int(n) - 1) << 1) + 1)) for n in stdin.read().split()])) 23 | stdout.write('\n') 24 | -------------------------------------------------------------------------------- /SPOJ/AE00_Rectangles/Rectangles.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AE00 - Rectangles 2 | # Author : Wojciech Raszka 3 | # Date created : 4 | # Description : 5 | # Status : Accepted (???) 6 | # Tags : R 7 | # Comment : 8 | 9 | 10 | f <- file('stdin', open='r') 11 | 12 | N = as.integer(readLines(f, n=1)) 13 | 14 | no_of_rectangles = N 15 | 16 | root_of_N = as.integer(sqrt(N)) 17 | i = 2 18 | while (i <= root_of_N){ 19 | for (j in i:as.integer(N/i)){ 20 | no_of_rectangles = no_of_rectangles + 1 21 | } 22 | i = i + 1 23 | } 24 | 25 | write(no_of_rectangles, stdout()) 26 | -------------------------------------------------------------------------------- /SPOJ/AE1B_Tables/Tables.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AE1B - Tables 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-06 4 | # Description : 5 | # Status : Accepted (23185689) 6 | # Comment : 7 | 8 | n, k, s = list(map(int, input().split(' '))) 9 | 10 | A = sorted(map(int, input().split(' ')), reverse=True) 11 | 12 | needed_no_of_screws = k*s 13 | cum_no_of_screws = 0 14 | 15 | no_of_boxes = 0 16 | for no_of_screws in A: 17 | cum_no_of_screws += no_of_screws 18 | no_of_boxes += 1 19 | if cum_no_of_screws >= needed_no_of_screws: 20 | print(no_of_boxes) 21 | break 22 | -------------------------------------------------------------------------------- /SPOJ/AGPC01F - Can you search/Can you search.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AGPC01F - Can you search? 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-04-16 5 | # Description : 6 | # Status : Accepted (23644182) 7 | # Tags : python, sliding window technique 8 | # Comment : 9 | 10 | def min_(x): 11 | global min_val 12 | 13 | x = int(x) 14 | if x < min_val: 15 | min_val = x 16 | 17 | return min_val 18 | 19 | T = int(raw_input()) 20 | 21 | while T > 0: 22 | tokens = raw_input().split() 23 | if len(tokens) < 2: 24 | continue 25 | n, q = map(int, tokens) 26 | 27 | min_val = 10**5 + 1 28 | A = [min_(x) for x in raw_input().split()] 29 | print '\n'.join(map(lambda x: str(A[int(x) - 1]) , raw_input().split())) 30 | 31 | T -= 1 32 | -------------------------------------------------------------------------------- /SPOJ/AGPREFX - Agent prefix/Agent prefix.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AGPREFX - Agent prefix 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-29 4 | # Description : 5 | # Status : Accepted (23523093) 6 | # Tags : python 7 | # Comment : 8 | 9 | agency_name = raw_input() 10 | idx = int(raw_input()) 11 | msg = raw_input() 12 | 13 | cyphred_msg = msg[:idx] + 'LUISS' + msg[idx + len(agency_name):] 14 | 15 | print(cyphred_msg) 16 | -------------------------------------------------------------------------------- /SPOJ/ALCATRAZ1_Sum of digits/Sum of digits.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ALCATRAZ1 - Sum of digits 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-06 4 | # Description : 5 | # Status : Time limit exceeded 6 | # Comment : I think it is imposible to do in R. Reading input takes more time than it is given. 7 | 8 | f <- file('stdin', open='r') 9 | 10 | T = readLines(f, n=1) 11 | 12 | for (t in 1:T){ 13 | n <- readLines(f, n=1) 14 | 15 | write(sum(as.integer(unlist(strsplit(n, split='')))), stdout()) 16 | } 17 | -------------------------------------------------------------------------------- /SPOJ/ALCATRAZ1_Sum of digits/Sum of digits.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ALCATRAZ1 - Sum of digits 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-06 4 | # Description : 5 | # Status : Accepted (23185785) 6 | # Comment : 7 | 8 | T = int(input()) 9 | 10 | for i in range(T): 11 | print(sum(map(int, input()))) 12 | -------------------------------------------------------------------------------- /SPOJ/ALICESIE - Alice Sieve/Alice Sieve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: ALICESIE - Alice Sieve 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-16 6 | # Description : 7 | # Status : Accepted (23426591) 8 | # Comment : The first and only (n + 1)/2 numbers are unmarked. 9 | 10 | read T 11 | 12 | for ((t = 1; t <= T; t++ )) 13 | do 14 | read n 15 | echo $((($n + 1)/2)) 16 | done 17 | -------------------------------------------------------------------------------- /SPOJ/AMR10G_Christmas Play/Christmas Play.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AMR10G - Christmas Play 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-08 5 | # Description : 6 | # Status : Accepted (23367585) 7 | # Tags : python 8 | # Comment : 9 | 10 | T = int(input()) 11 | 12 | for t in range(T): 13 | N, K = map(int, input().split()) 14 | K -= 1 15 | 16 | if K > 0: 17 | smallest_heights_diff = 1000000000 18 | heights = sorted(map(int, input().split())) 19 | 20 | for i in range(len(heights) - K): 21 | if heights[i + K] - heights[i] < smallest_heights_diff: 22 | smallest_heights_diff = heights[i + K] - heights[i] 23 | else: 24 | smallest_heights_diff = 0 25 | input() 26 | 27 | print(smallest_heights_diff) 28 | -------------------------------------------------------------------------------- /SPOJ/ANARC08E - Relax! It is just a game/Relax! It is just a game.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ANARC08E - Relax! It is just a game 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-14 5 | # Description : 6 | # Status : Accepted (23633884) 7 | # Tags : python, math, combinatorics 8 | # Comment : 9 | 10 | while True: 11 | a, b = map(int, input().split()) 12 | if a == -1 or b == -1: 13 | break 14 | elif a + b - 1 == a or 1 == a: 15 | print(a, "+", b, "=", a + b, sep="") 16 | else: 17 | print(a, "+", b, "!=", a + b, sep="") 18 | -------------------------------------------------------------------------------- /SPOJ/ANARC09B - Tiles of Tetris, Not!/Tiles of Tetris, Not!.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ANARC09B - Tiles of Tetris, Not! 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-11 5 | # Description : 6 | # Status : Accepted (23619376) 7 | # Tags : python, geometry, GCD, greatest common divisor 8 | # Comment : 9 | 10 | def gcd(a, b): 11 | if b == 0: 12 | return a 13 | 14 | return gcd(b, a % b) 15 | 16 | while True: 17 | a, b = map(int, input().split()) 18 | if a == b == 0: 19 | break 20 | 21 | if a == b: 22 | print(1) 23 | else: 24 | r = gcd(a, b) 25 | print(a*b//(r*r)) 26 | -------------------------------------------------------------------------------- /SPOJ/ARMY - Army Strength/Army Strength.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ARMY - Army Strength 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-11-18 5 | # Description : 6 | # Status : Accepted (24893661) 7 | # Tags : python, game theory 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | T = int(stdin.readline()) 13 | 14 | while T > 0: 15 | stdin.readline() #read empty line 16 | ng, nm = map(int, stdin.readline().split()) 17 | godzilla_best_soldier = max(map(int, stdin.readline().split())) 18 | mechagodzilla_best_soldier = max(map(int, stdin.readline().split())) 19 | 20 | if godzilla_best_soldier >= mechagodzilla_best_soldier: 21 | stdout.write('Godzilla\n') 22 | else: 23 | stdout.write('MechaGodzilla\n') 24 | 25 | T -= 1 26 | -------------------------------------------------------------------------------- /SPOJ/ARRANGE - Arranging Amplifiers/Arranging Amplifiers.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ARRANGE - Arranging Amplifiers 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-11-20 5 | # Description : 6 | # Status : Accepted (24907533) 7 | # Tags : python 8 | # Comment : Inq. 1 9 | 10 | from sys import stdin, stdout 11 | 12 | T = int(stdin.readline()) 13 | 14 | while T > 0: 15 | n = int(stdin.readline()) 16 | A = [int(x) for x in stdin.readline().split()] 17 | A.sort(reverse=True) 18 | if len(A) >= 2 and A[0] == 3 and A[1] == 2: 19 | A[0] = 2 20 | A[1] = 3 21 | 22 | try: 23 | idx_1 = A.index(1) 24 | A = A[idx_1:] + A[:idx_1] 25 | except: 26 | pass 27 | 28 | stdout.write(' '.join([str(a) for a in A]) + '\n') 29 | T -= 1 30 | -------------------------------------------------------------------------------- /SPOJ/AVG - AVERAGE/AVERAGE.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AVG - AVERAGE 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-14 5 | # Description : 6 | # Status : Accepted (23634195) 7 | # Tags : python, math, arithmetic average 8 | # Comment : 9 | 10 | T = int(raw_input()) 11 | 12 | while T > 0: 13 | n = int(raw_input()) 14 | print sum(map(int, raw_input().split()))/n 15 | T -= 1 16 | -------------------------------------------------------------------------------- /SPOJ/AVRG - Simple Average/Simple Average.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: AVRG - Simple Average 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-14 5 | # Description : 6 | # Status : Accepted (23634126) 7 | # Tags : python, math, average 8 | # Comment : 9 | 10 | import sys 11 | 12 | print(sum(map(float, sys.stdin))/6) 13 | -------------------------------------------------------------------------------- /SPOJ/BACTERIA - SPOJ Custom Test/SPOJ Custom Test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: BACTERIA - SPOJ Custom Test 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-11 6 | # Description : 7 | # Status : Accepted (23386957) 8 | # Tags : bash 9 | # Comment : 10 | 11 | echo Let\'s party 12 | -------------------------------------------------------------------------------- /SPOJ/BALLSUM_Ball sum/Ball sum.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BALLSUM - Game store 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-10 4 | # Description : 5 | # Status : Accepted (23207470) 6 | # Comment : 7 | 8 | 9 | from math import ceil 10 | from fractions import gcd 11 | 12 | N, K = input().split() 13 | N, K = int(N), int(K) 14 | 15 | while K != -1 and N != -1: 16 | #p = N*(N - 1) - (N - 1)*(N - K) - (2*N - K + 1)*K//2 + ceil(K/2) 17 | p = (K*(K - 1)//2 - K//2)//2 18 | #q = N*(N - 1) 19 | q = N*(N - 1)//2 20 | 21 | if p == 0: 22 | print(0) 23 | else: 24 | nwd = gcd(p, q) 25 | print(p//nwd, "/", q//nwd, sep="") 26 | 27 | N, K = input().split() 28 | N, K = int(N), int(K) 29 | -------------------------------------------------------------------------------- /SPOJ/BFWRITE - Brainf F##k Writing/Brainf F##k Writing.bf: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BFWRITE - Brainf F##k Writing 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-28 5 | # Description : 6 | # Status : Accepted (23694748) 7 | # Tags : brainfuck 8 | # Comment : 154 chars 9 | 10 | ++++[>++++<-]>[>+++++>++>++>++<<<<-]>+++.---.-.-----.>.>++++[>++>+++>+++<<<-]>+.>+++++++.<<<.>>.>>++.<<-----.+..-.<<.>>---.>++++.<++++.>----.>+.--.<<. 11 | -------------------------------------------------------------------------------- /SPOJ/BFXYZ - BrainFked/BrainFked.bf: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BFXYZ - BrainF**ked 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-29 5 | # Description : 6 | # Status : Accepted (23514402) 7 | # Tags : brainfuck 8 | # Comment : 75 chars 9 | 10 | +++++++[>+++<-]>+[>++++>+++<<-]>.+.+.>-.<----.---------.++++++.>+++++++.<+. 11 | -------------------------------------------------------------------------------- /SPOJ/BINARYIO - Binary Input and Output/Binary Input and Output.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: BINARYIO - Binary Input and Output 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-03-10 5 | * Description : 6 | * Status : Accepted (23379792) 7 | * Comment : 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | int main(){ 14 | double x; 15 | 16 | while (fread(&x, sizeof(x), 1, stdin) == 1){ 17 | x = log(x); 18 | fwrite(&x, sizeof(x), 1, stdout); 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /SPOJ/BINARYIO - Binary Input and Output/Binary Input and Output.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BINARYIO - Binary Input and Output 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-10 4 | # Description : 5 | # Status : Accepted (23379972) 6 | # Comment : 7 | 8 | import sys 9 | import struct 10 | from math import log 11 | 12 | for block in iter(lambda: sys.stdin.buffer.read(8), ""): 13 | if block: 14 | x = log(struct.unpack("d", block)[0]) 15 | sys.stdout.buffer.write(struct.pack("d", x)) 16 | else: 17 | break 18 | -------------------------------------------------------------------------------- /SPOJ/BINARYIO - Binary Input and Output/Binary Input and Output_v2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: BINARYIO - Binary Input and Output 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-03-10 5 | * Description : 6 | * Status : Accepted (23379855) 7 | * Comment : 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | int main(){ 14 | const int MAX_SIZE = 1000000; 15 | double x[MAX_SIZE]; 16 | 17 | size_t no_of_ret = fread(x, sizeof *x, MAX_SIZE, stdin); 18 | for (int i = 0; i < no_of_ret; i++){ 19 | x[i] = log(x[i]); 20 | } 21 | 22 | fwrite(x, sizeof *x, no_of_ret, stdout); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /SPOJ/BINARYIO - Binary Input and Output/Binary Input and Output_v2.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BINARYIO - Binary Input and Output 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-10 4 | # Description : 5 | # Status : Accepted (23380003) 6 | # Comment : 7 | 8 | import sys 9 | import struct 10 | from math import log 11 | 12 | inp = sys.stdin.buffer.read() 13 | no_of_ret = len(inp)//8 14 | sys.stdout.buffer.write(struct.pack("%sd" % no_of_ret, *(list(map(lambda x: log(x), struct.unpack("%sd" % no_of_ret, inp)))))) 15 | -------------------------------------------------------------------------------- /SPOJ/BINARYIO - Binary Input and Output/Binary Input and Output_v3.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BINARYIO - Binary Input and Output 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-10 4 | # Description : 5 | # Status : Accepted (23380016) 6 | # Comment : 7 | 8 | import sys 9 | import struct 10 | from math import log 11 | 12 | inp = sys.stdin.buffer.read() 13 | no_of_ret = len(inp)//8 14 | sys.stdout.buffer.write(b''.join(map(lambda x: struct.pack("d", log(x)), struct.unpack("%sd" % no_of_ret, inp)))) 15 | -------------------------------------------------------------------------------- /SPOJ/BINSTIRL - Binary Stirling Numbers/Binary Stirling Numbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: BINSTIRL - Binary Stirling Numbers 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-31 6 | # Description : 7 | # Status : Accepted (23533595) 8 | # Tags : bash, the Stirling number of the second kind, the parity of a Stirling number of the second kind, Sierpiński triangle 9 | # Comment : 10 | 11 | read T 12 | 13 | for ((t = 0; t < T; t++)) 14 | do 15 | read n m 16 | 17 | if [ $m -eq 0 ] && [ $n -gt 0 ]; then 18 | echo 0 19 | else 20 | z=$(($n - ($m + 2)/2)) 21 | w=$((($m - 1)/2)) 22 | if [ $(($z&$w)) -eq $w ]; then 23 | echo 1 24 | else 25 | echo 0 26 | fi 27 | fi 28 | done 29 | -------------------------------------------------------------------------------- /SPOJ/BISHOPS_Bishops/Bishops.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BISHOPS - Bishops 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-08 4 | # Description : 5 | # Status : Accepted (23195535) 6 | # Comment : 7 | 8 | library(gmp, warn.conflicts=FALSE) 9 | 10 | f <- file('stdin', open='r') 11 | 12 | N = readLines(f, n=-1, warn=FALSE) 13 | 14 | for (n in N){ 15 | if (n == 1) 16 | write(1, stdout()) 17 | else 18 | write(as.character(2*as.bigq(n) - 2), stdout()) 19 | } 20 | -------------------------------------------------------------------------------- /SPOJ/BOOKGFT_Book Gift/Book Gift.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BOOKGFT - Book Gift 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-23 4 | # Description : 5 | # Status : Accepted (23283389) 6 | # Comment : 7 | 8 | T = int(input()) 9 | 10 | for t in range(T): 11 | M, N = map(int, input().split()) 12 | if N % M == 0: 13 | print("YES") 14 | else: 15 | print("NO") 16 | -------------------------------------------------------------------------------- /SPOJ/BSCXOR_XOR/XOR.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: BSCXOR - XOR 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-02-03 6 | # Description : 7 | # Status : Accepted (23207495) 8 | # Tags : bash 9 | # Comment : 10 | 11 | read p q 12 | 13 | echo $(($p ^ $q)) 14 | -------------------------------------------------------------------------------- /SPOJ/BUET19_Map/35355_Map.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: BUET19 - Map 3 | * Author : Wojciech Raszka 4 | * E-mail : contact@gitpistachio.com 5 | * Date created : 6 | * Description : 7 | * Status : 8 | * Tags : c++ 9 | * Comment : 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() { 18 | int N; 19 | 20 | cin >> N; 21 | set IDs; 22 | if (N == 1) { 23 | cout << 1 << endl; 24 | } 25 | else{ 26 | bool display; 27 | int no_of_unique_id = 0; 28 | int id; 29 | for (int i=0; i> id; 32 | 33 | IDs.insert(id); 34 | } 35 | cout << IDs.size() << endl; 36 | } 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /SPOJ/BUET19_Map/35355_Map.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: BUET19 - Map 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 5 | # Description : 6 | # Status : 7 | # Tags : python 8 | # Comment : 9 | 10 | N = int(input()) 11 | 12 | offlines = set(map(int, input().split())) 13 | 14 | print(len(offlines)) 15 | -------------------------------------------------------------------------------- /SPOJ/CANDY3_Candy III/Candy III.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CANDY3 - Candy III 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-02-07 5 | # Description : 6 | # Status : Accepted (23191601) 7 | # Tags : python 8 | # Comment : 9 | 10 | 11 | T = int(input()) 12 | 13 | for t in range(T): 14 | input() 15 | N = int(input()) 16 | sum_of_candy = sum([int(input()) for i in range(N)]) 17 | if sum_of_candy % N == 0: 18 | print('YES') 19 | else: 20 | print('NO') 21 | -------------------------------------------------------------------------------- /SPOJ/CATXAT - CAT and XAT/CAT and XAT.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: CATXAT - CAT and XAT 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-31 6 | # Description : 7 | # Status : Accepted (23537643) 8 | # Tags : bash 9 | # Comment : 10 | 11 | LETTERS=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) 12 | 13 | function getCode(){ 14 | if [ $1 == " " ]; then 15 | echo "" 16 | else 17 | j=0 18 | while [ ${LETTERS[j]} != $1 ] 19 | do 20 | ((j++)) 21 | done 22 | echo ${LETTERS[(j+23)%26]}${LETTERS[(j+4)%26]} 23 | fi 24 | } 25 | 26 | read T 27 | 28 | for ((t = 0; t < T; t++)) 29 | do 30 | read s 31 | ts="" 32 | for ((i = 0; i < ${#s}; i++ )) 33 | do 34 | ts=$ts$(getCode "${s:$i:1}") 35 | done 36 | echo $ts 37 | done 38 | -------------------------------------------------------------------------------- /SPOJ/CDRSANJ - CODER FIRST PROBLEM/CODER FIRST PROBLEM.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: CDRSANJ - CODER FIRST PROBLEM 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-04-02 7 | # Description : 8 | # Status : Accepted (23554223) 9 | # Tags : bash 10 | # Comment : F(n) = n for n <= 2 and F(2^k*m) = 2*k where m = 0 or m is odd for the rest n F(n) = 0 11 | 12 | read x 13 | 14 | if [ $x -lt 3 ]; then 15 | echo $x 16 | else 17 | F=0 18 | while [ $x -gt 0 ] && [ $(($x % 2)) -eq 0 ] 19 | do 20 | F=$(($F+2)) 21 | x=$(($x/2)) 22 | done 23 | 24 | echo $F 25 | fi 26 | -------------------------------------------------------------------------------- /SPOJ/CHITEST1_Sum of two numbers/Sum of two numbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: CHITEST1 - Sum of two numbers 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-02-10 6 | # Description : 7 | # Status : Accepted (23205366) 8 | # Comment : 9 | 10 | read i 11 | until [ $i -lt 0 ] 12 | do 13 | read a b 14 | echo "$a+$b" | bc 15 | let i-=1 16 | done 17 | -------------------------------------------------------------------------------- /SPOJ/CHI_EXP - The real exponential/CHI_EXP - The real exponential_v2.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CHI_EXP - The real exponential 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-11-17 5 | # Description : 6 | # Status : Accepted (24885907) 7 | # Tags : python, bignum arithmetic 8 | # Comment : 10 points 9 | 10 | from decimal import * 11 | import re 12 | 13 | getcontext().prec = 102 14 | 15 | def normalize(x): 16 | x = str(x.normalize()).replace('.', '') 17 | x = re.sub(r'^0+', '', x) 18 | x = x[:101] 19 | x = re.sub(r'0+$', '', x) 20 | 21 | return x if x != '' else 0 22 | 23 | T = int(raw_input()) 24 | 25 | while T > 0: 26 | n = Decimal(raw_input()) 27 | if n == Decimal('0'): 28 | print '1' 29 | else: 30 | print normalize(n.exp()) 31 | T -= 1 32 | -------------------------------------------------------------------------------- /SPOJ/CHI_LOG - The real logarithm/The real logarithm.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CHI_LOG - The real logarithm 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-21 5 | # Description : 6 | # Status : Accepted (23668073) 7 | # Tags : python, bignum arithmetic 8 | # Comment : 9 | 10 | from decimal import * 11 | 12 | getcontext().prec = 102 13 | 14 | T = int(raw_input()) 15 | 16 | while T > 0: 17 | n = Decimal(raw_input()) 18 | if n == Decimal('1'): 19 | print '0' 20 | else: 21 | print str(n.ln()).strip("0").replace(".", "") 22 | T -= 1 23 | -------------------------------------------------------------------------------- /SPOJ/CODECODE - Coder Or NonCoder/Coder Or NonCoder.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CODECODE - Coder Or NonCoder 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-23 4 | # Description : 5 | # Status : Accepted (23477201) 6 | # Tags : R, math, probability theory 7 | # Comment : O(1) 8 | 9 | f <- file('stdin', open='r') 10 | 11 | T <- as.integer(readLines(f, n=1)) 12 | 13 | while (T > 0){ 14 | tokens <- as.integer(unlist(strsplit(readLines(f, n=1), ' '))) 15 | x <- tokens[1]/100. 16 | y <- tokens[2]/100. 17 | 18 | res <- (1 - x)*(1 - y) + x*y 19 | write(paste(format(res*100, nsmall=2), "%", sep=""), stdout()) 20 | T = T - 1 21 | } 22 | -------------------------------------------------------------------------------- /SPOJ/CODEM1 - Problem1/Problem1.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CODEM1 - Problem1 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-09 4 | # Description : 5 | # Status : Accepted (23370155) 6 | # Comment : The question should be: Is it possible to determine if sum of given three numbers is positive, negative or 0 7 | 8 | T = int(input()) 9 | 10 | def NVL(a, b, c): 11 | if a == '$' and b == '$': 12 | return c 13 | elif a == '$': 14 | return b 15 | else: 16 | return a 17 | 18 | for t in range(T): 19 | a,b,c = list(input()) 20 | if NVL(a, b, c) == NVL(b, c, a) == NVL(c, a, b): 21 | print('possible') 22 | else: 23 | print('trivial') 24 | -------------------------------------------------------------------------------- /SPOJ/CODEM2 - Problem2/Problem2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: CODEM2 - Problem2 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-04-03 7 | # Description : 8 | # Status : Accepted (23562683) 9 | # Tags : bash, Fermat Last Theorem, Diophantine equation, probability theory, pythagorean triple 10 | # Comment : From given condition is result as a solving equation x^n + y^2 = z^2 for n > 2 which has no solution in integer domain 11 | 12 | read T 13 | 14 | for ((t = 0; t < $T; t++)) 15 | do 16 | read n x y 17 | if [ $n -eq 1 ]; then 18 | echo $(($x + $y)) 19 | elif [ $n -eq 2 ]; then 20 | echo "sqrt($x*$x + $y*$y)" | bc 21 | else 22 | echo impossible 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /SPOJ/CPTTRN1 - Character Patterns (Act 1)/Character Patterns (Act 1).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CPTTRN1 - Character Patterns (Act 1) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-23 4 | # Description : 5 | # Status : Accepted (23283637) 6 | # Comment : 7 | 8 | def drawPattern(n, m): 9 | odd = "*."*(m//2) + ("*" if m % 2 == 1 else "") 10 | even = ".*"*(m//2) + ("." if m % 2 == 1 else "") 11 | for is_odd in [True, False]*(n//2): 12 | if is_odd: 13 | print(odd) 14 | else: 15 | print(even) 16 | 17 | if n % 2 == 1: 18 | print(odd) 19 | 20 | T = int(input()) 21 | 22 | for t in range(T): 23 | n, m = map(int, input().split()) 24 | drawPattern(n, m) 25 | 26 | if t + 1 < T: 27 | print() 28 | -------------------------------------------------------------------------------- /SPOJ/CPTTRN2 - Character Patterns (Act 2)/Character Patterns (Act 2).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CPTTRN2 - Character Patterns (Act 2) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-23 4 | # Description : 5 | # Status : Accepted(23283688) 6 | # Comment : 7 | 8 | def drawPattern(n, m): 9 | if n > 0: 10 | print("*"*m) 11 | if n > 1: 12 | if m <= 2: 13 | inner_row = "*"*m 14 | else: 15 | inner_row = "*" + "."*(m-2) + "*" 16 | 17 | for i in range(n - 2): 18 | print(inner_row) 19 | 20 | print("*"*m) 21 | 22 | T = int(input()) 23 | 24 | for t in range(T): 25 | n, m = map(int, input().split()) 26 | drawPattern(n, m) 27 | 28 | if t + 1 < T: 29 | print() 30 | -------------------------------------------------------------------------------- /SPOJ/CPTTRN3 - Character Patterns (Act 3)/Character Patterns (Act 3).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CPTTRN3 - Character Patterns (Act 3) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-23 4 | # Description : 5 | # Status : Accepted (23283814) 6 | # Comment : 7 | 8 | def drawPattern(n, m): 9 | print("*"*(3*m + 1)) 10 | inner_row = "*.."*m + "*" 11 | for i in range(n): 12 | print(inner_row) 13 | print(inner_row) 14 | print("*"*(3*m + 1)) 15 | 16 | T = int(input()) 17 | 18 | for t in range(T): 19 | n, m = map(int, input().split()) 20 | drawPattern(n, m) 21 | 22 | if t + 1 < T: 23 | print() 24 | -------------------------------------------------------------------------------- /SPOJ/CPTTRN4 - Character Patterns (Act 4)/Character Patterns (Act 4).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CPTTRN4 - Character Patterns (Act 4) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-23 4 | # Description : 5 | # Status : Accepted (23283889) 6 | # Comment : 7 | 8 | def drawPattern(n, m, h, w): 9 | print("*"*((1 + w)*m + 1)) 10 | inner_row = ("*" + "."*w)*m + "*" 11 | for i in range(n): 12 | for j in range(h): 13 | print(inner_row) 14 | print("*"*((1 + w)*m + 1)) 15 | 16 | T = int(input()) 17 | 18 | for t in range(T): 19 | n, m, h, w = map(int, input().split()) 20 | drawPattern(n, m, h, w) 21 | 22 | if t + 1 < T: 23 | print() 24 | -------------------------------------------------------------------------------- /SPOJ/CPTTRN6 - Character Patterns (Act 6)/Character Patterns (Act 6).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CPTTRN6 - Character Patterns (Act 6) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-23 4 | # Description : 5 | # Status : Accepted (23284441) 6 | # Comment : 7 | 8 | def drawPattern(n, m, h, w): 9 | for i in range(n): 10 | for j in range(h): 11 | print('|'.join(['.'*w]*(m + 1))) 12 | if i + 1 < n: 13 | print('+'.join(['-'*w]*(m + 1))) 14 | 15 | 16 | T = int(input()) 17 | 18 | for t in range(T): 19 | n, m, h, w = map(int, input().split()) 20 | drawPattern(n + 1, m, h, w) 21 | 22 | if t + 1 < T: 23 | print() 24 | -------------------------------------------------------------------------------- /SPOJ/CRDS - Cards/Cards.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CRDS - Cards 2 | # Author : Wojciech Raszka 3 | # Date created : 4 | # Description : 5 | # Status : Accepted (23536964) 6 | # Tags : R, integer sequence A005449 (OEIS) 7 | # Comment : a(n) = n*(3*n + 1)/2 8 | 9 | options(scipen=999) 10 | 11 | f <- file('stdin', open='r') 12 | 13 | T <- as.integer(readLines(f, n=1)) 14 | 15 | #N <- as.integer(readLines(f, n=T)) 16 | N <- read.table(f) #faster 17 | 18 | An <- N*(3*N + 1)/2 19 | 20 | write.table(An %% 1000007, file=stdout(), quote=FALSE, row.names=FALSE, col.names=FALSE, sep=' ') 21 | -------------------------------------------------------------------------------- /SPOJ/CRS - Crying Series/Crying Series.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CRS - Crying Series 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-09 4 | # Description : 5 | # Status : Accepted (23373929) 6 | # Tags : python 7 | # Comment : 8 | 9 | import sys 10 | 11 | for line in sys.stdin: 12 | n = int(line) 13 | 14 | F = (n + 1)//2 15 | if n % 2: 16 | F = -F 17 | 18 | print(F) 19 | -------------------------------------------------------------------------------- /SPOJ/CSUMQ - Cumulative Sum Query/Cumulative Sum Query.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: G11 - Binario 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-04-02 5 | # Description : 6 | # Status : Accepted (23562331) 7 | # Tags : python, prefix sum, cumulative sum 8 | # Comment : 9 | 10 | n = int(input()) 11 | 12 | cumulative_sum = 0 13 | def rollingSum(x): 14 | x = int(x) 15 | global cumulative_sum 16 | 17 | cumulative_sum += x 18 | return cumulative_sum 19 | 20 | A = [0] 21 | A.extend([rollingSum(x) for x in input().split()]) 22 | 23 | Q = int(input()) 24 | 25 | for q in range(Q): 26 | i, j = map(int, input().split()) 27 | print(A[j + 1] - A[i]) 28 | -------------------------------------------------------------------------------- /SPOJ/CUBES_Perfect Cubes/Perfect Cubes.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Candy III 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-08 4 | # Description : 5 | # Status : Accepted (23195938) 6 | # Comment : 7 | from math import floor, ceil 8 | 9 | 10 | for a in range(6, 101): 11 | cube_of_a = a*a*a 12 | no_of_operations = 0 13 | for b in range(2, a - 1): 14 | cube_of_b = b*b*b 15 | eq = floor((cube_of_a - cube_of_b)**(1/3)) 16 | for c in range(b, eq + 1): 17 | no_of_operations += 1 18 | cube_of_c = c*c*c 19 | cube_of_d = cube_of_a - cube_of_b - cube_of_c 20 | d = ceil((cube_of_a - cube_of_b - cube_of_c)**(1/3)) 21 | if d*d*d == cube_of_d and d >= c: 22 | print("Cube = ", a, ", Triple = (", b, ",", c, ",", d, ")", sep='') 23 | -------------------------------------------------------------------------------- /SPOJ/DAYOUT2A - Reverse Words/Reverse Words.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: DAYOUT2A - Reverse Words 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-05 7 | # Description : 8 | # Status : Accepted (23884097) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 0; t < $T; t++)); do 14 | read sentence 15 | words=(${sentence}) 16 | n=${#words[@]} 17 | echo -n ${words[$(($n - 1))]} 18 | for ((i = $(($n - 2)); i >= 0; i--)); do 19 | echo -n " ${words[i]}" 20 | done 21 | echo "" 22 | done 23 | -------------------------------------------------------------------------------- /SPOJ/DAYOUT2B - Binary/Binary.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: DAYOUT2B - Binary 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-05 7 | # Description : 8 | # Status : Accepted (23884283) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 0; t < $T; t++)); do 14 | read d 15 | n=$((2**(d - 1))) 16 | n2=$((2*n)) 17 | if [[ $d -eq 1 ]]; then 18 | echo 0 19 | fi 20 | for ((i = $n; i < n2; i++)); do 21 | echo "obase=2;$i" | bc 22 | done 23 | done 24 | -------------------------------------------------------------------------------- /SPOJ/DAYOUT2D - Dragons/Dragons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: DAYOUT2D - Dragons 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-05 7 | # Description : 8 | # Status : Accepted (23884478) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)); do 14 | read line_of_soldiers 15 | read dragon 16 | 17 | echo -n "Case $t: " 18 | echo $line_of_soldiers | grep -o $dragon | wc -l 19 | done 20 | -------------------------------------------------------------------------------- /SPOJ/DAYOUT2E - Big Dragons/Big Dragons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: DAYOUT2E - Big Dragons 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-05 7 | # Description : 8 | # Status : Accepted (23884553) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)); do 14 | read line_of_soldiers 15 | read dragon 16 | 17 | m=${#dragon} 18 | n=$((${#line_of_soldiers} - $m + 1)) 19 | no_of_dragons=0 20 | for i in $(seq 1 $n); do 21 | if [ ${line_of_soldiers:i-1:$m} == $dragon ]; then 22 | let "no_of_dragons++" 23 | fi 24 | done 25 | echo "Case $t: $no_of_dragons" 26 | done 27 | -------------------------------------------------------------------------------- /SPOJ/DAYOUT2F - More Dragons/More Dragons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: DAYOUT2F - More Dragons 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-05 7 | # Description : 8 | # Status : Accepted (23884607) 9 | # Tags : bash 10 | # Comment : Only pure vowels 11 | 12 | vowels=(a e i o u A E I O U) 13 | 14 | read T 15 | for ((t = 1; t <= $T; t++)); do 16 | read line_of_soldiers 17 | read start end 18 | 19 | echo -n "Case $t: " 20 | no_of_dragons=0 21 | n=$((${#vowels[@]} - 1)) 22 | for i in $(seq 0 $n); do 23 | 24 | let "no_of_dragons+=$(echo ${line_of_soldiers:$start-1:$end-$start+1} | grep -o ${vowels[i]} | wc -l)" 25 | done 26 | echo "$no_of_dragons" 27 | done 28 | -------------------------------------------------------------------------------- /SPOJ/DELEVE - Somma i numeri dispari/Somma i numeri dispari.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: DELEVE - Somma i numeri dispari 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-27 5 | # Description : 6 | # Status : Accepted (23506306) 7 | # Tags : python 8 | # Comment : 9 | 10 | A = eval(input()) 11 | 12 | print(sum(map(lambda x: x if x % 2 else 0, A))) 13 | -------------------------------------------------------------------------------- /SPOJ/DOL - Largest Odd Divisor/Largest Odd Divisor.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: DOL - Largest Odd Divisor 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-13 5 | # Description : 6 | # Status : Accepted (23629799) 7 | # Tags : python, largest odd divisor 8 | # Comment : 9 | 10 | T = int(raw_input()) 11 | 12 | for t in xrange(T): 13 | n = int(raw_input()) 14 | 15 | while n & 1 == 0: 16 | n = n >> 1 17 | 18 | print "Case " + str(t + 1) + ": " + str(n) 19 | -------------------------------------------------------------------------------- /SPOJ/EASYMRKS_Easy Marks/25306_Easy Marks.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: EASYMRKS - Easy Marks 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 5 | # Description : 6 | # Status : 7 | # Tags : python 8 | # Comment : 9 | 10 | import math 11 | 12 | T = int(input()) 13 | 14 | for i in range(1, T + 1): 15 | N, K = list(map(int, input().split(' '))) 16 | sum_of_n = sum(map(int, input().split(' '))) 17 | print('Case ', i, ': ', math.floor(K*(N + 1) - sum_of_n), sep='') 18 | T -= 1 19 | -------------------------------------------------------------------------------- /SPOJ/EBOXES - Empty Boxes/Empty Boxes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: EBOXES - Empty Boxes 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 7 | # Description : 8 | # Status : Accepted (23643085) 9 | # Tags : bash, math 10 | # Comment : O(1) solution. Answer N + K*(F - N)/(K - 1) 11 | 12 | read T 13 | 14 | for((t = 0; t < $T; t++)) 15 | do 16 | read N K R F 17 | 18 | echo $(($N + $K*($F - $N)/($K - 1))) 19 | done 20 | -------------------------------------------------------------------------------- /SPOJ/EC_CONB_Even Numbers/Even Numbers.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Even numbers 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-10 4 | # Description : 5 | # Status : Accepted (23204625) 6 | # Comment : 7 | 8 | 9 | N = int(raw_input()) 10 | 11 | for i in range(N): 12 | n = int(input()) 13 | if (n % 2 == 0): 14 | print int(bin(n)[:1:-1], 2) 15 | else: 16 | print n 17 | -------------------------------------------------------------------------------- /SPOJ/EIGHTS_Triple fat ladies/Triple fat ladies.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Triple fat ladies 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-06 4 | # Description : 5 | # Status : Accepted (23186394) 6 | # Comment : 1 -> 192; 2 -> 422 = 192 + (2 - 1) * 250; 3 -> 692 = 192 + (3 - 1) * 250; 4 -> 942 = 192 + (4 - 1) * 250 etc 7 | 8 | library(gmp, warn.conflicts=FALSE) 9 | 10 | f <- file('stdin', open='r') 11 | 12 | t <- as.integer(readLines(f, n=1)) 13 | 14 | for (i in 1:t){ 15 | k <- as.bigq(readLines(f, n=1)) 16 | 17 | eee <- 192 + (k - 1)*250 18 | write(as.character(eee), stdout()) 19 | } 20 | -------------------------------------------------------------------------------- /SPOJ/ENCAROC - Occurrences of a Character/Occurrences of a Character.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ENCAROC - Occurrences of a Character 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-24 4 | # Description : 5 | # Status : Accepted (23483741) 6 | # Tags : python 7 | # Comment : 8 | 9 | sentence = input() 10 | letter = input().strip() 11 | 12 | print(len(sentence)- len(sentence.replace(letter, ""))) 13 | -------------------------------------------------------------------------------- /SPOJ/ENGCD - Greatest Common Divisor/Greatest Common Divisor.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ENGCD - Greatest Common Divisor 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-24 4 | # Description : 5 | # Status : Accepted (23483764) 6 | # Tags : python, GCD, greatest common divisor 7 | # Comment : 8 | 9 | def gcd(a, b): 10 | while b: 11 | a, b = b, a % b 12 | 13 | return a 14 | 15 | print(gcd(int(input()), int(input()))) 16 | -------------------------------------------------------------------------------- /SPOJ/ENIGMATH - PLAY WITH MATH/PLAY WITH MATH.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ENIGMATH - PLAY WITH MATH 2 | # Author : Wojciech Raszka 3 | # Date created : 4 | # Description : 5 | # Status : Accepted (23536665) 6 | # Tags : R, gcd, greatest common divisior, linear Diophantine equation 7 | # Comment : 8 | 9 | gcd <- function(x){ 10 | while (x[2] != 0){ 11 | t = x[2] 12 | x[2] = x[1] %% x[2] 13 | x[1] = t 14 | } 15 | return (x[1]) 16 | } 17 | 18 | f <- file('stdin', open='r') 19 | 20 | T <- as.integer(readLines(f, n=1)) 21 | 22 | 23 | X <- matrix(0, T, 2) 24 | A <- read.table(f) 25 | 26 | d <- apply(A, 1, gcd) 27 | X[, 1] <- A[, 2]/d 28 | X[, 2] <- A[, 1]/d 29 | 30 | 31 | write.table(trimws(format(X, scientific=FALSE)), file=stdout(), quote=FALSE, row.names=FALSE, col.names=FALSE, sep=' ') 32 | -------------------------------------------------------------------------------- /SPOJ/ENIGMATH - PLAY WITH MATH/PLAY WITH MATH_v2.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ENIGMATH - PLAY WITH MATH 2 | # Author : Wojciech Raszka 3 | # Date created : 4 | # Description : 5 | # Status : Accepted (23536766) 6 | # Tags : R, gcd, greatest common divisior, linear Diophantine equation 7 | # Comment : 8 | 9 | options(scipen=999) 10 | 11 | gcd <- function(x){ 12 | while (x[2] != 0){ 13 | t = x[2] 14 | x[2] = x[1] %% x[2] 15 | x[1] = t 16 | } 17 | return (x[1]) 18 | } 19 | 20 | f <- file('stdin', open='r') 21 | 22 | T <- as.integer(readLines(f, n=1)) 23 | 24 | A <- read.table(f) 25 | 26 | d <- apply(A, 1, gcd) 27 | 28 | write.table((A/d)[,2:1], file=stdout(), quote=FALSE, row.names=FALSE, col.names=FALSE, sep=' ') 29 | -------------------------------------------------------------------------------- /SPOJ/ENLCD - Lowest Common Denominator/Lowest Common Denominator.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ENLCD - Lowest Common Denominator 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-24 4 | # Description : 5 | # Status : Accepted (23483754) 6 | # Tags : python, LCM, lowest common denominator, GCD, greatest common divisor 7 | # Comment : 8 | 9 | def gcd(a, b): 10 | while b: 11 | a, b = b, a % b 12 | 13 | return a 14 | 15 | def lcm(a, b): 16 | return a*b//gcd(a, b) 17 | 18 | print(lcm(int(input()), int(input()))) 19 | -------------------------------------------------------------------------------- /SPOJ/ENPRIME - Prime Number/Prime Number.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ENPRIME - Prime Number 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-25 4 | # Description : 5 | # Status : Accepted (23483831) 6 | # Tags : python, factorial 7 | # Comment : 8 | 9 | from functools import reduce 10 | 11 | N = int(input()) 12 | if N <= 1: 13 | print(1) 14 | else: 15 | print(reduce(lambda x, y: x*y, range(1, N + 1))) 16 | -------------------------------------------------------------------------------- /SPOJ/EXPECT - Life, the Universe, and Everything (Interactive)/Life, the Universe, and Everything (Interactive).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: EXPECT - Life, the Universe, and Everything (Interactive) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-11 4 | # Description : 5 | # Status : Accepted (23387007) 6 | # Comment : 7 | 8 | while True: 9 | ans = input() 10 | if ans == '42': 11 | print(ans, flush=True) 12 | break 13 | print(ans, flush=True) 14 | -------------------------------------------------------------------------------- /SPOJ/EXPECT - Life, the Universe, and Everything (Interactive)/Life, the Universe, and Everything (Interactive).sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: EXPECT - Life, the Universe, and Everything (Interactive) 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-11 6 | # Description : 7 | # Status : Accepted (23386996) 8 | # Comment : 9 | 10 | while true 11 | do 12 | read line 13 | if [ $line -eq 42 ] 14 | then 15 | echo $line 16 | exit 0 17 | fi 18 | echo $line 19 | done 20 | -------------------------------------------------------------------------------- /SPOJ/FASHION_Fashion Shows/Fashion shows.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Sum of digits 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-06 4 | # Description : 5 | # Status : Accepted (23186673) 6 | # Comment : 7 | 8 | T = int(input()) 9 | 10 | for t in range(T): 11 | N = int(input()) 12 | 13 | hotness_levels_of_men = sorted(map(int, input().split(' '))) 14 | hotness_levels_of_women = sorted(map(int, input().split(' '))) 15 | 16 | sum_of_hotness_bonds = 0 17 | for i in range(N): 18 | sum_of_hotness_bonds += hotness_levels_of_men[i]*hotness_levels_of_women[i] 19 | print(sum_of_hotness_bonds) 20 | -------------------------------------------------------------------------------- /SPOJ/FAST2 - Fast Sum of two to an exponent/Fast Sum of two to an exponent.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: FAST2 - Fast Sum of two to an exponent 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-18 4 | # Description : 5 | # Status : Accepted (23441642) 6 | # Comment : Precomputed prefix sum 7 | 8 | from sys import stdin, stdout 9 | 10 | mod = 1298074214633706835075030044377087 11 | 12 | T = int(stdin.readline()) 13 | 14 | X = [1] 15 | Y = [1] 16 | for i in range(500): 17 | X.append((2*X[i]) % mod) 18 | Y.append((Y[i] + X[i + 1]) % mod) 19 | 20 | stdout.write('\n'.join(map(lambda n: str(Y[int(n)]), stdin))) 21 | -------------------------------------------------------------------------------- /SPOJ/FCTRL2_Small factorials/24_Small factorials.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Sum of digits 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-03 4 | # Description : 5 | # Status : Accepted (???) 6 | # Comment : 7 | 8 | library(gmp, warn.conflicts=FALSE) 9 | 10 | f <- file('stdin', open='r') 11 | 12 | N = readLines(f, n=-1, warn=FALSE) 13 | 14 | for (n in N){ 15 | write(as.character(2*as.bigq(n) - 2), stdout()) 16 | } 17 | -------------------------------------------------------------------------------- /SPOJ/FCTRL2_Small factorials/24_Small factorials.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: FCTRL2 - Small factorials 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 5 | # Description : 6 | # Status : 7 | # Tags : python 8 | # Comment : 9 | 10 | def factorial(n): 11 | if n > 1: 12 | return n*factorial(n - 1) 13 | 14 | return 1 15 | 16 | test_cases = int(input()) 17 | numbers = [int(input()) for tc in range(test_cases)] 18 | 19 | for n in numbers: 20 | print(factorial(n)) 21 | -------------------------------------------------------------------------------- /SPOJ/FCTRL_Factorial/11_Factorial.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: FCTRL - Factorial 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 5 | # Description : 6 | # Status : 7 | # Tags : R 8 | # Comment : 9 | 10 | Z <- function(n){ 11 | d <- 5 12 | no_of_zeros <- 0 13 | while (d <= n){ 14 | no_of_zeros = no_of_zeros + n%/%d 15 | d = d*5 16 | } 17 | return (as.integer(no_of_zeros)) 18 | } 19 | 20 | f <- file('stdin', open='r') 21 | 22 | T = as.integer(readLines(f, n=1)) 23 | N = integer(T) 24 | for (n in 1:T){ 25 | write(Z(as.integer(readLines(f, n=1))), stdout()) 26 | } 27 | -------------------------------------------------------------------------------- /SPOJ/FCTRL_Factorial/11_Factorial.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: FCTRL - Factorial 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 5 | # Description : 6 | # Status : 7 | # Tags : python 8 | # Comment : 9 | 10 | def Z(n): 11 | d = 5 12 | no_of_zeros = 0 13 | while d <= n: 14 | no_of_zeros += n//d 15 | d *= 5 16 | 17 | return no_of_zeros 18 | 19 | T = int(input()) 20 | N = [int(input()) for i in range(T)] 21 | 22 | for n in N: 23 | print(Z(n)) 24 | -------------------------------------------------------------------------------- /SPOJ/FCTRL_Factorial/11_Factorial.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: FCTRL - Factorial 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 7 | # Description : 8 | # Status : Accepted (23571513) 9 | # Tags : bash, math, factorial, noumber of zeros at the end of an number, integer sequence A027868 (OEIS) 10 | # Comment : 11 | 12 | read T 13 | for ((i=1; i<=$T; i++)) 14 | do 15 | read n 16 | echo $(($n/5 + $n/25 + $n/125 + $n/625 + $n/3125 + $n/15625 + $n/78125 + $n/390625 + $n/1953125 + $n/9765625 +$n/48828125 + $n/244140625)) 17 | done 18 | -------------------------------------------------------------------------------- /SPOJ/FCTRL_Factorial/FCTRL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: FCTRL - Factorial 3 | * Author : Wojciech Raszka 4 | * E-mail : gitpistachio@gmail.com 5 | * Date created : 2019-??-?? 6 | * Description : 7 | * Status : 8 | * Tags : java, math,factorial 9 | * Comment : 10 | */ 11 | 12 | import java.util.Scanner; 13 | 14 | class FCTRL 15 | { 16 | public static int Z(int n) 17 | { 18 | int d = 5; 19 | int no_of_zeros = 0; 20 | while (d <= n){ 21 | no_of_zeros += n/d; 22 | d *= 5; 23 | } 24 | return no_of_zeros; 25 | } 26 | public static void main(String[] args) 27 | { 28 | Scanner sc = new Scanner(System.in); 29 | int T = sc.nextInt(); 30 | for (int i=0; i b: 16 | print('>') 17 | else: 18 | print('=') 19 | 20 | a, b = input().split() 21 | -------------------------------------------------------------------------------- /SPOJ/HMBY_Hablu Wants to Buy/Hablu Wants to Buy.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: HMBY - Hablu Wants to Buy 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-16 4 | # Description : 5 | # Status : Accepted (23241231) 6 | # Comment : 7 | 8 | library(gmp, warn.conflicts=FALSE) 9 | 10 | f <- file('stdin', open='r') 11 | 12 | n <- unlist(strsplit(readLines(f, n=1), ' ')) 13 | w = as.bigz(n[6]) 14 | 15 | sum_of_notes = 2*as.bigz(n[1]) + 4*as.bigz(n[2]) + 8*as.bigz(n[3]) + 16*as.bigz(n[4]) + 32*as.bigz(n[5]) 16 | 17 | if (w %% 2 == 0 && sum_of_notes >= w){ 18 | write("YES", stdout()) 19 | } else{ 20 | write("NO", stdout()) 21 | } 22 | -------------------------------------------------------------------------------- /SPOJ/HUBULLU - Hubulullu/Hubulullu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: HUBULLU - Hubulullu 4 | # Link : https://www.spoj.com/problems/HUBULLU/ 5 | # Try it on : https://ideone.com/W3UDAh 6 | # Author : Wojciech Raszka 7 | # Email : contact@gitpistachio.site 8 | # Date created : 2019-03-16 9 | # Description : 10 | # Status : Accepted (26042419) 11 | # Tags : bash, game theory 12 | # Comment : 13 | 14 | read T 15 | 16 | for ((t = 1; t <= T; t++ )) 17 | do 18 | read n 19 | echo $((($n + 1)/2)) 20 | done 21 | -------------------------------------------------------------------------------- /SPOJ/ICANDIES - Candies/ICANDIES.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: ICANDIES - Candies 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-03-09 5 | * Description : 6 | * Status : Accepted (23373828) 7 | * Comment : 8 | */ 9 | 10 | 11 | import java.util.Scanner; 12 | 13 | class ICANDIES{ 14 | public static void main(String args[]){ 15 | Scanner sc = new Scanner(System.in); 16 | 17 | int T = sc.nextInt(); 18 | int i, n; 19 | 20 | for (int t = 0; t < T; t++){ 21 | n = sc.nextInt(); 22 | for (i = 5; i < n - 3; i+=5){ 23 | if ((n - i) % 3 == 0) break; 24 | } 25 | if (n - i >= 3 && (n - i) % 3 == 0){ 26 | System.out.println("Case " + (t + 1) + ": " + (n - i)); 27 | } else { 28 | System.out.println("Case " + (t + 1) + ": -1"); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SPOJ/IEEEBGAM_The Ball Game/The Ball Game.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: The ball game 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-12 4 | # Description : 5 | # Status : Time Limit exceeded 6 | # Comment : The max probability is when N-1 boxes have exacly one white ball and non black balls. The rest of balls is in the last box. 7 | 8 | 9 | f = file('stdin', open='r') 10 | 11 | T = as.integer(readLines(f, n=1)) 12 | 13 | for (t in 1:T){ 14 | N = as.integer(readLines(f, n=1)) 15 | p = ((N - 1) + 1/(N + 1))/N 16 | write(format(round(p, 8), nsmall=8), stdout()) 17 | } 18 | -------------------------------------------------------------------------------- /SPOJ/IEEEBGAM_The Ball Game/The Ball Game.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: The ball game 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-02-12 5 | # Description : 6 | # Status : Accepted (23218850) 7 | # Tags : python, math, probability theory, combinatorics 8 | # Comment : The max probability is when N-1 boxes have exacly one white ball and non black balls. The rest of balls is in the last box. 9 | 10 | T = int(input()) 11 | 12 | for t in range(T): 13 | N = int(input()) 14 | p = round(((N - 1) + 1/(N + 1))/N, 8) 15 | print("{:.8f}".format(p)) 16 | -------------------------------------------------------------------------------- /SPOJ/IITKWPCB - Check the coprimeness/Check the coprimeness.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: IITKWPCB - Check the coprimeness 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-06-16 5 | # Description : 6 | # Status : Accepted (23927989) 7 | # Tags : python, math, coprime 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | T = int(stdin.readline()) 13 | 14 | while T > 0: 15 | x = int(stdin.readline()) 16 | y = (x + 1)//4 17 | 18 | if x > 2: 19 | res = 1 + (y - 1)*2 20 | r = (x + 1) % 4 21 | if r == 2: 22 | res += 1 23 | else: 24 | res = 1 25 | 26 | stdout.write('%d\n' % res) 27 | 28 | T -= 1 29 | -------------------------------------------------------------------------------- /SPOJ/INFINITY - Biggest !/Biggest !.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: INFINITY - Biggest ! 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-04-09 5 | * Description : 6 | * Status : Accepted (23607763) 7 | * Tags : c 8 | * Comment : 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | int main() 16 | { 17 | setlocale( LC_ALL, "en_US.UTF-8" ); 18 | wprintf (L"%lc\n", 8734); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /SPOJ/INFINITY - Biggest !/Biggest !.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: INFINITY - Biggest ! 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-02-09 5 | * Description : 6 | * Status : Accepted (23201679) 7 | * Tags : c++ 8 | * Comment : 9 | */ 10 | 11 | #include 12 | using namespace std; 13 | 14 | int main() { 15 | std::cout << "\u221E"; 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /SPOJ/INFSUC - Basics/Basics.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: INFSUC - Basics 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-04-09 5 | * Description : 6 | * Status : Accepted (23607795) 7 | * Tags : c 8 | * Comment : 9 | */ 10 | 11 | main(){puts("Success\n\u221E");} 12 | -------------------------------------------------------------------------------- /SPOJ/INFSUC - Basics/Basics_v2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: INFSUC - Basics 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-04-09 5 | * Description : 6 | * Status : Accepted (23607913) 7 | * Tags : c 8 | * Comment : %m is GNU extension to prinft. See stackoverflow topic 20577557 9 | */ 10 | 11 | main(){printf("%m\n\u221E");} 12 | -------------------------------------------------------------------------------- /SPOJ/INOROUT - Inside or outside/samples/input1.txt: -------------------------------------------------------------------------------- 1 | 3 3 2 | 0 0 3 0 0 3 3 | -1 -1 4 | 0 0 5 | 1 1 -------------------------------------------------------------------------------- /SPOJ/INOROUT - Inside or outside/samples/input2.txt: -------------------------------------------------------------------------------- 1 | 5 5 2 | 0 0 1 0 3 0 6 0 8 6 3 | 4 3 4 | -1 -1 5 | 0 0 6 | 6 1 7 | 7 1 -------------------------------------------------------------------------------- /SPOJ/INOROUT - Inside or outside/samples/output1.txt: -------------------------------------------------------------------------------- 1 | F 2 | D 3 | D -------------------------------------------------------------------------------- /SPOJ/INOROUT - Inside or outside/samples/output2.txt: -------------------------------------------------------------------------------- 1 | D 2 | F 3 | D 4 | D 5 | F -------------------------------------------------------------------------------- /SPOJ/INTEST - Enormous Input Test/Enormous Input Test.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: INTEST - Enormous Input Test 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-15 4 | # Description : 5 | # Status : Accepted (23420587) 6 | # Comment : 7 | 8 | f <- file('stdin', open='r') 9 | 10 | p <- unlist(strsplit(readLines(f, n=1) , ' ')) 11 | 12 | n <- as.integer(p[1]) 13 | k <- as.integer(p[2]) 14 | 15 | write(sum(as.integer(readLines(f, n=n)) %% k == 0), stdout()) 16 | -------------------------------------------------------------------------------- /SPOJ/INTEST - Enormous Input Test/Enormous Input Test.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: INTEST - Enormous Input Test 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-15 4 | # Description : 5 | # Status : Accepted (23420289) 6 | # Comment : 7 | 8 | from sys import stdin, stdout 9 | 10 | n, k = map(int, stdin.readline().split()) 11 | 12 | stdout.write(str(sum(map(lambda x: 1 if int(x) % k == 0 else 0 , stdin)))) 13 | -------------------------------------------------------------------------------- /SPOJ/JADDOU3 - Jaddouic Sequence/Jaddouic Sequence.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: JADDOU3 - Jaddouic Sequence 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-05-12 5 | # Description : 6 | # Status : Accepted (23754408) 7 | # Tags : python, modulo power, integer sequence A007582 (OEIS) 8 | # Comment : 9 | 10 | import sys 11 | 12 | 13 | def power(x, y, p): 14 | result = 1 15 | x = x % p 16 | while y > 0: 17 | if y & 1 == 1: 18 | result = (result * x) % p 19 | 20 | y = y >> 1 21 | x = (x * x) % p 22 | 23 | return result 24 | 25 | n = int(sys.stdin.readline()) 26 | 27 | p = 123456789 28 | a_n = power(2, n - 1, p) 29 | b_n = (2*a_n*a_n + a_n) % p 30 | 31 | sys.stdout.write(str(b_n)) 32 | -------------------------------------------------------------------------------- /SPOJ/JULKA - Julka/Julka.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: JULKA - Julka 2 | # Link : https://www.spoj.com/problems/JULKA/ 3 | # Try it on : https://ideone.com/3iZ5ff 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.site 6 | # Date created : 2020-05-26 7 | # Description : 8 | # Status : Accepted (26042577) 9 | # Tags : python, big numbers 10 | # Comment : 11 | 12 | from sys import stdin, stdout 13 | 14 | NO_OF_TESTS = 10 15 | 16 | for _ in range(NO_OF_TESTS): 17 | z = int(stdin.readline()) 18 | d = int(stdin.readline()) 19 | y = (z - d)//2 20 | x = z - y 21 | 22 | stdout.write("{}\n{}\n".format(x, y)) -------------------------------------------------------------------------------- /SPOJ/KIDZEE1B - Sum It Up/Sum It Up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1B - Sum It Up 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23860945) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read x y z 16 | echo Case $t: Sum of $x, $y and $z is $(($x + $y + $z)) 17 | done 18 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1C - Multiple of 3/Multiple of 3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1C - Multiple of 3 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23860998) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read n 16 | if [ $n != "" ]; then 17 | if [ $(($n % 3)) -eq 0 ]; then 18 | echo $n is a multiple of 3 19 | else 20 | echo $n is not a multiple of 3 21 | fi 22 | else 23 | t=$(($t - 1)) 24 | fi 25 | done 26 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1E - Sort them All/Sort them All.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1E - Sort them All 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862021) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read n1 n2 n3 16 | if [ $n1 -le $n2 ]; then 17 | if [ $n3 -ge $n2 ]; then 18 | echo Case $t: $n1 $n2 $n3 19 | elif [ $n3 -ge $n1 ]; then 20 | echo Case $t: $n1 $n3 $n2 21 | else 22 | echo Case $t: $n3 $n1 $n2 23 | fi 24 | else 25 | if [ $n3 -le $n2 ]; then 26 | echo Case $t: $n3 $n2 $n1 27 | elif [ $n3 -le $n1 ]; then 28 | echo Case $t: $n2 $n3 $n1 29 | else 30 | echo Case $t: $n2 $n1 $n3 31 | fi 32 | fi 33 | done 34 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1F - Easy as Cake/Easy as Cake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1F - Easy as Cake 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862034) 9 | # Tags : bash 10 | # Comment : 11 | 12 | for ((i = 1000; i > 0; i--)) 13 | do 14 | echo $i 15 | done 16 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1G - Multiples/Multiples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1G - Multiples 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862088) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read x n 16 | echo -n Case $t: 17 | for ((i = 1; i <= $n; i++)) 18 | do 19 | if [ $(($i*$x)) -le $n ]; then 20 | echo -n " $(($i*$x))" 21 | else 22 | break 23 | fi 24 | done 25 | echo "" 26 | done 27 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1H - Digital Triangle/Digital Triangle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1H - Digital Triangle 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862116) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read d h 16 | 17 | echo Case $t: 18 | for ((i = 0; i < $h; i++)); do 19 | for ((j = 0; j <= $i; j++)); do 20 | echo -n $d 21 | done 22 | echo "" 23 | done 24 | done 25 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1I - In Love with Loops/In Love with Loops.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1I - In Love with Loops 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862159) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read A B C 16 | 17 | echo Case $t: 18 | for ((x = 0; x <= $A; x++)); do 19 | for ((y = $(($x + 1)); y <= $B; y++)); do 20 | for ((z = $(($y + 1)); z <= $C; z++)); do 21 | echo $x $y $z 22 | done 23 | done 24 | done 25 | done 26 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1J - Divisors/Divisors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1J - Divisors 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862322) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read n 16 | 17 | echo -n Case $t: 18 | tail="" 19 | for ((i = 1; i*i <= $n; i++)); do 20 | if [ $(($n % $i)) -eq 0 ]; then 21 | echo -n " $i" 22 | if [ $(($i*$i)) -ne $n ]; then 23 | tail=" $(($n/$i))$tail" 24 | fi 25 | fi 26 | done 27 | echo "$tail" 28 | done 29 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1K - Fun Triangle/Fun Triangle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1K - Fun Triangle 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862337) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read a h 16 | echo "Case $t: $(($a*$h))" 17 | done 18 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1N - Rectangle Intersection/Rectangle Intersection.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1N - Rectangle Intersection 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862791) 9 | # Tags : bash, intersection of rectangles 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read x1 y1 x2 y2 16 | read x3 y3 x4 y4 17 | if [ $y3 -ge $y2 ] || [ $y1 -ge $y4 ]; then 18 | echo "Case $t: No" 19 | elif [ $x3 -ge $x2 ] || [ $x1 -ge $x4 ]; then 20 | echo "Case $t: No" 21 | else 22 | echo "Case $t: Yes" 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1O - Kings on an Infinite Chessboard/Kings on an Infinite Chessboard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1O - Kings on an Infinite Chessboard 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862847) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read r1 c1 r2 c2 16 | r=$(($r1 - r2)) 17 | r=${r#-} 18 | 19 | c=$(($c1 - c2)) 20 | c=${c#-} 21 | 22 | if [ $r -le $c ]; then 23 | d=$r 24 | else 25 | d=$c 26 | fi 27 | 28 | echo "Case $t: $(($r + $c - $d))" 29 | done 30 | -------------------------------------------------------------------------------- /SPOJ/KIDZEE1P - Progression/Progression.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: KIDZEE1P - Progression 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-01 7 | # Description : 8 | # Status : Accepted (23862865) 9 | # Tags : bash, arithmetic progression, geometric progression 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)) 14 | do 15 | read a b c 16 | 17 | if [ $(($c - $b - $b + $a)) -eq 0 ]; then 18 | if [ $(($b*$b - $a*$c)) -eq 0 ]; then 19 | echo "Case $t: Both" 20 | else 21 | echo "Case $t: Arithmetic Progression" 22 | fi 23 | elif [ $(($b*$b - $a*$c)) -eq 0 ]; then 24 | echo "Case $t: Geometric Progression" 25 | else 26 | echo "Case $t: None" 27 | fi 28 | done 29 | -------------------------------------------------------------------------------- /SPOJ/KNJIGE - KNJIGE/KNJIGE.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: KNJIGE - KNJIGE 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2021-03-12 5 | # Description : 6 | # Status : Accepted (27545906) 7 | # Tags : python, restricted sort 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | no_of_books = int(stdin.readline()) 13 | books = [int(stdin.readline()) for _ in range(no_of_books)] 14 | 15 | last_value = no_of_books + 1 16 | no_of_steps = no_of_books 17 | for value in books[::-1]: 18 | if value == last_value - 1: 19 | no_of_steps -= 1 20 | last_value = value 21 | 22 | stdout.write('{}\n'.format(no_of_steps)) -------------------------------------------------------------------------------- /SPOJ/LASTDIG - The last digit/The last digit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: LASTDIG - The last digit 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-04-01 7 | # Description : 8 | # Status : Accepted (23545257) 9 | # Tags : bash, number theory, last digit 10 | # Comment : 11 | 12 | C=(0 0 0 0 1 1 1 1 2 4 8 6 3 9 7 1 4 6 4 6 5 5 5 5 6 6 6 6 7 9 3 1 8 4 2 6 9 1 9 1) 13 | 14 | read T 15 | 16 | for ((t = 0; t < T; t++ )) 17 | do 18 | read a b 19 | a=$(($a % 10)) 20 | if [ $b -eq 0 ]; then 21 | echo 1 22 | else 23 | b=$((($b - 1) % 4)) 24 | echo ${C[a*4 + b]} 25 | fi 26 | done 27 | -------------------------------------------------------------------------------- /SPOJ/LASTDIG2 - The last digit re-visited/The last digit re-visited.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: LASTDIG2 - The last digit re-visited 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-04-01 4 | # Description : 5 | # Status : Accepted (23545539) 6 | # Tags : python, number theory, last digit, big numbers 7 | # Comment : pypy 8 | 9 | C=(0,0,0,0,1,1,1,1,2,4,8,6,3,9,7,1,4,6,4,6,5,5,5,5,6,6,6,6,7,9,3,1,8,4,2,6,9,1,9,1) 10 | T = int(raw_input()) 11 | 12 | for t in range(T): 13 | a, b = raw_input().split() 14 | a = int(a[-1]) 15 | b = int(b) 16 | 17 | if a == b: 18 | print 0 19 | elif b == 0: 20 | print 1 21 | else: 22 | b = (b - 1)% 4 23 | print C[4*a + b] 24 | -------------------------------------------------------------------------------- /SPOJ/LGIC - LOGIC/LOGIC.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: LGIC - LOGIC 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-30 4 | # Description : 5 | # Status : Accepted (23526325) 6 | # Tags : python, factorial 7 | # Comment : 8 | 9 | def getNthTerm(n): 10 | a = 1 11 | b = 1 12 | for i in range(2, n + 1): 13 | a *= i 14 | b = 2*b + i - 2 15 | 16 | return a + b 17 | 18 | 19 | n = int(input()) 20 | 21 | print(getNthTerm(n)) 22 | -------------------------------------------------------------------------------- /SPOJ/M3TILE - LATGACH3/LATGACH3.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: M3TILE - LATGACH3 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-04-14 5 | # Description : 6 | # Status : Accepted (23634235) 7 | # Tags : python, integer sequence A001835 (OEIS) 8 | # Comment : 9 | 10 | def a(n): 11 | if n == 0 or n == 1: 12 | return 1 13 | 14 | return 4*a(n - 1) - a(n - 2) 15 | 16 | 17 | while True: 18 | n = int(input()) 19 | if n == -1: 20 | break 21 | elif n == 0: 22 | print(1) 23 | elif n & 1: 24 | print(0) 25 | else: 26 | print(a(n//2 + 1)) 27 | -------------------------------------------------------------------------------- /SPOJ/MADODDSUM_Easy Odd Sum/Easy Odd Sum.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MADODDSUM - Easy Odd Sum 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-08 4 | # Description : 5 | # Status : Accepted (23367652) 6 | # Tags : python, sum of odd numbers 7 | # Comment : 8 | 9 | a, b = map(int, input().split()) 10 | 11 | a += (a + 1) % 2 12 | b -= (b + 1) % 2 13 | 14 | if b >= a: 15 | n = (b - a)//2 + 1 16 | print((a + b)//2*n) 17 | else: 18 | print(0) 19 | -------------------------------------------------------------------------------- /SPOJ/MAGGNUM - Trova il numero maggiore/Trova il numero maggiore.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MAGGNUM - Trova il numero maggiore 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-27 4 | # Description : 5 | # Status : 6 | # Tags : python 7 | # Comment : 8 | 9 | A = eval(input()) 10 | 11 | if len(A): 12 | print(max(A)) 13 | else: 14 | print(0) 15 | -------------------------------------------------------------------------------- /SPOJ/MAIN12A_SelfDescribingSequenceProblem/SelfDescribingSequenceProblem.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MAIN12A - SelfDescribingSequenceProblem 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-15 4 | # Description : 5 | # Status : Accepted (23238763) 6 | # Comment : 7 | 8 | 9 | sq = [1] 10 | 11 | last = 2 12 | for i in range(6136): 13 | sq += [last]*sq[i] 14 | last += 1 15 | 16 | T = int(input()) 17 | 18 | for t in range(T): 19 | print("Case #", t + 1, ": ", sq[int(input()) - 1], sep="") 20 | -------------------------------------------------------------------------------- /SPOJ/MANGOES - Real Mangoes for Ranjith/Real Mangoes for Ranjith.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: MANGOES - Real Mangoes for Ranjith 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-17 6 | # Description : 7 | # Status : Accepted (23433248) 8 | # Comment : 9 | 10 | read T 11 | 12 | for ((t = 1; t <= T; t++ )) 13 | do 14 | read n 15 | if (($n % 2 == 0)) 16 | then 17 | echo $((($n - 2)*($n - 2)/4 % $n)) 18 | else 19 | echo $((($n - 1)*($n - 1)/4 % $n)) 20 | fi 21 | done 22 | -------------------------------------------------------------------------------- /SPOJ/MARBLES - Marbles/Marbles.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MARBLES - Marbles 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-04-18 5 | # Description : 6 | # Status : Accepted (23196497) 7 | # Tags : python, combinations without repetition, math, combinatorics 8 | # Comment : C(n - 1, k - 1) 9 | 10 | 11 | def combination(n, k): 12 | if k > n - k: 13 | k = n - k 14 | 15 | no_of_possibilities = 1 16 | 17 | for i in range(k): 18 | no_of_possibilities = no_of_possibilities*(n - i)//(i + 1) 19 | 20 | return no_of_possibilities 21 | 22 | 23 | T = int(input()) 24 | 25 | while T > 0: 26 | n, k = map(int, input().split()) 27 | 28 | print(combination(n - 1, k - 1)) 29 | 30 | T -= 1 31 | -------------------------------------------------------------------------------- /SPOJ/MASUM01 - Fame seeker Masum/Fame seeker Masum.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MASUM01 - Fame seeker Masum 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-11-12 5 | # Description : 6 | # Status : Accepted (24842653) 7 | # Tags : python, string pattern 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | word = 'masum' 13 | 14 | i = 0 15 | j = 0 16 | rejected_idx = [] 17 | for letter in stdin.readline().strip(): 18 | if j >= len(word) or letter != word[j]: 19 | rejected_idx.append(str(i + 1)) 20 | else: 21 | j += 1 22 | 23 | i += 1 24 | 25 | 26 | if len(rejected_idx) == 0: 27 | stdout.write('Nothing to delete') 28 | else: 29 | stdout.write(' '.join(rejected_idx)) 30 | -------------------------------------------------------------------------------- /SPOJ/MAXLN - THE MAX LINES/THE MAX LINES.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: MAXLN - THE MAX LINES 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-15 6 | # Description : 7 | # Status : Accepted (23420815) 8 | # Comment : s(x) = 2r^2 -2xr + sqrt(2r^2 + 2xr), thus the max is s(0.125/r - r) = (2r)^2 + 0.25 9 | 10 | read T 11 | 12 | for ((t = 1; t <= T; t++ )) 13 | do 14 | read r 15 | s=$(echo "2*2*$r*$r + 0.25" | bc -l) 16 | printf "Case $t: %.2f\n" "$s" 17 | done 18 | -------------------------------------------------------------------------------- /SPOJ/MCDLUS - Massimo Comune Divisore/Massimo Comune Divisore.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MAGGNUM - Trova il numero maggiore 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-27 5 | # Description : 6 | # Status : Accepted (23506348) 7 | # Tags : python, gcd, greatest common divisor 8 | # Comment : 9 | 10 | def gcd(a, b): 11 | while b: 12 | a, b = b, a % b 13 | 14 | return a 15 | 16 | A = eval(input()) 17 | 18 | print(gcd(A[0], A[1])) 19 | -------------------------------------------------------------------------------- /SPOJ/MFLAR10 - Flowers Flourish from France/Flowers Flourish from France.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MFLAR10 - Flowers Flourish from France 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-17 4 | # Description : 5 | # Status : Accepted (23427291) 6 | # Comment : 7 | 8 | import sys 9 | 10 | for sentence in sys.stdin: 11 | if sentence != '*\n': 12 | if len(set(map(lambda x: x[0].lower() , sentence.split()))) == 1: 13 | print('Y') 14 | else: 15 | print('N') 16 | elif sentence != '\n': 17 | break 18 | -------------------------------------------------------------------------------- /SPOJ/MOZGEOL - Jenny the GeoLover/Jenny the GeoLover.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MOZGEOL - Jenny the GeoLover 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-21 5 | # Description : 6 | # Status : Accepted (23669744) 7 | # Tags : python, math, geometry, right-angle trinalge 8 | # Comment : 9 | 10 | from math import sin, radians 11 | 12 | T = int(input()) 13 | 14 | for t in range(1, T + 1): 15 | b, angle = map(float, input().split()) 16 | 17 | h = b/sin(radians(angle)) 18 | print("Case ", t, ": ", '{:6f}'.format(h), sep="") 19 | -------------------------------------------------------------------------------- /SPOJ/MOZMTF - Mozahid the forgetful/Mozahid the forgetful.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MOZMTF - Mozahid the forgetful 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-22 5 | # Description : 6 | # Status : Accepted (23670146) 7 | # Tags : python 8 | # Comment : 9 | 10 | n = input() 11 | A = list(map(int, n)) 12 | s = int(input()) - sum(A) 13 | 14 | res = '' 15 | for i in range(10): 16 | if s <= A[i]: 17 | res += n[i] 18 | else: 19 | res += str(s) + n[i:] 20 | break 21 | else: 22 | res += str(s) 23 | 24 | print(res) 25 | -------------------------------------------------------------------------------- /SPOJ/MOZPAS - Prangon and String/Prangon and String.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MOZPAS - Prangon and String 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-21 5 | # Description : 6 | # Status : Accepted (23669618) 7 | # Tags : python 8 | # Comment : 9 | 10 | import string 11 | n, m = map(int, input().split()) 12 | 13 | 14 | prangon = '' 15 | for l in string.ascii_letters: 16 | 17 | prangon += l*min(n - len(prangon), m) 18 | 19 | if len(prangon) == n: 20 | print(prangon) 21 | break 22 | -------------------------------------------------------------------------------- /SPOJ/MOZSACP - Sharmeen And C Programming/Sharmeen And C Programming.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: MOZSACP - Sharmeen And C Programming 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-11-13 7 | # Description : 8 | # Status : Accepted (24854750) 9 | # Tags : bash 10 | # Comment : 11 | 12 | echo "C Programming" 13 | -------------------------------------------------------------------------------- /SPOJ/MOZSAEO - Sharmeen and Even Odd/Sharmeen and Even Odd.sh: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MOZSAEO - Sharmeen and Even Odd 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 5 | # Description : 6 | # Status : Accepted (23669655) 7 | # Tags : bash 8 | # Comment : 9 | 10 | #!/bin/bash 11 | 12 | read T 13 | 14 | for((t = 0; t < $T; t++)) 15 | do 16 | read a b 17 | a="${a: -1}" 18 | b="${b: -1}" 19 | if [ $((($a + $b) % 2)) -eq 1 ]; then 20 | echo odd 21 | else 22 | echo even 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /SPOJ/MOZSAHTF - Sharmeen And Her Two Friends/Sharmeen And Her Two Friends.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: MOZSAHTF - Sharmeen And Her Two Friends 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-11-12 7 | # Description : 8 | # Status : Accepted (24842960) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read d 13 | 14 | if [ $(($d % 2)) -eq 1 ]; then 15 | echo "Samira" 16 | else 17 | echo "Rabeya" 18 | fi 19 | -------------------------------------------------------------------------------- /SPOJ/MOZSAO - Sharmeen and One/Sharmeen and One.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MOZSAO - Sharmeen and One 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-22 5 | # Description : 6 | # Status : Accepted (23669247) 7 | # Tags : python 8 | # Comment : 9 | 10 | T = int(input()) 11 | 12 | while T > 0: 13 | n = int(input()) 14 | 15 | print(' '.join(['one']*n) + '!'*n) 16 | T -= 1 17 | -------------------------------------------------------------------------------- /SPOJ/MOZSATDOW - Sharmeen and the day of week/Sharmeen and the day of week.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MOZSATDOW - Sharmeen and the day of week 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-11-13 5 | # Description : 6 | # Status : Accepted (24854150) 7 | # Tags : python 8 | # Comment : 9 | 10 | days = {0 : 'Friday', 1 : 'Saturday', 2 : 'Sunday', 3 : 'Monday', 4 : 'Tuesday', 5 : 'Wednesday', 6 : 'Thursday'} 11 | 12 | n = int(stdin.readline()) 13 | 14 | stdout.write('%s\n' % days[n % 7]) 15 | -------------------------------------------------------------------------------- /SPOJ/MOZSATDOW - Sharmeen and the day of week/Sharmeen and the day of week.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: MOZSATDOW - Sharmeen and the day of week 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-11-13 7 | # Description : 8 | # Status : Accepted (24854405) 9 | # Tags : bash 10 | # Comment : 11 | 12 | days=(Friday Saturday Sunday Monday Tuesday Wednesday Thursday) 13 | 14 | read n 15 | 16 | echo ${days[$(($n % 7))]} 17 | -------------------------------------------------------------------------------- /SPOJ/MUL - Fast Multiplication/Fast Multiplication.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MUL - Fast Multiplication 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachi@gmail.com 4 | # Date created : 2019-03-09 5 | # Description : 6 | # Status : Accepted (23373544) 7 | # Tags : python 8 | # Comment : 9 | 10 | T = int(input()) 11 | 12 | for t in range(T): 13 | l1, l2 = map(int, input().split()) 14 | print(l1*l2) 15 | -------------------------------------------------------------------------------- /SPOJ/MXMNDF - Differenza tra massimo e minimo in una lista/Differenza tra massimo e minimo in una lista.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: MXMNDF - Differenza tra massimo e minimo in una lista 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-27 4 | # Description : 5 | # Status : Accepted (23506354) 6 | # Tags : python 7 | # Comment : 8 | 9 | A = eval(input()) 10 | 11 | print(max(A) - min(A)) 12 | -------------------------------------------------------------------------------- /SPOJ/NEWTANK - Tanks/Tanks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: NEWTANK - Tanks 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 7 | # Description : 8 | # Status : Accepted (23639305) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read T 13 | 14 | for((i = 1; i <= $T; i++)) 15 | do 16 | read v t 17 | echo "Case #$i: $(($v*$t))" 18 | done 19 | -------------------------------------------------------------------------------- /SPOJ/NGM - A Game with Numbers/A Game with Numbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: NGM - A Game with Numbers 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-21 7 | # Description : 8 | # Status : Accepted (23955554) 9 | # Tags : bash, game theory 10 | # Comment : 11 | 12 | read n 13 | 14 | if [ $(($n % 10)) -eq 0 ]; then 15 | echo 2 16 | else 17 | echo 1 18 | echo $(($n % 10)) 19 | fi 20 | -------------------------------------------------------------------------------- /SPOJ/NODESC1 - No Description 1/No Description 1.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: NODESC1 - No Description 1 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-04-02 5 | # Description : 6 | # Status : Accepted (23555290) 7 | # Tags : python, fibonacci sequence, brute force 8 | # Comment : Solution: for n print F(n) chars '?', where F(n) is a fibonacci sequence 9 | 10 | def F(n): 11 | if n > 1: 12 | return F(n - 1) + F(n - 2) 13 | elif n == 1: 14 | return 1 15 | else: 16 | return 0 17 | 18 | n = int(input()) 19 | print("?"*F(n)) 20 | -------------------------------------------------------------------------------- /SPOJ/NSTEPS_Number Steps/Number Steps.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Game store 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-09 4 | # Description : 5 | # Status : Accepted (23206442) 6 | # Comment : 7 | 8 | N = int(input()) 9 | 10 | for n in range(N): 11 | x, y = input().split() 12 | x, y = int(x), int(y) 13 | 14 | if x == 0 and y == 0: 15 | print(0) 16 | elif x == 1 and y == 1: 17 | print(1) 18 | elif x == y: 19 | print(2*x -(x % 2)) 20 | elif y == x - 2: 21 | print(2*x - 2 - (x % 2)) 22 | else: 23 | print("No Number") 24 | -------------------------------------------------------------------------------- /SPOJ/NUMPATH - Gutibazi/NUMPATH.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: NUMPATH - Gutibazi 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-22 6 | # Description : 7 | # Status : Accepted (23476899) 8 | # Tags : bash, game theory, dynamic programming 9 | # Comment : 10 | 11 | MAX_N=7 12 | 13 | for ((i=0; i<2*$MAX_N; i++)) 14 | do 15 | arr[i*2*$MAX_N]=1 16 | arr[i]=1 17 | done 18 | 19 | for ((i=1; i<2*MAX_N; i++)) 20 | do 21 | for ((j=1; j<2*$MAX_N-i; j++)) 22 | do 23 | arr[i*2*MAX_N+j]=$((${arr[i*2*MAX_N+j - 1]} + ${arr[(i-1)*2*MAX_N+j]})) 24 | done 25 | done 26 | 27 | 28 | read T 29 | 30 | for ((i=0; i<$T; i++)) 31 | do 32 | read r c 33 | echo ${arr[(r-1)*2*MAX_N+c-1]} 34 | done 35 | -------------------------------------------------------------------------------- /SPOJ/NY10A_Penney Game/Penney Game.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Penney game 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-12 4 | # Description : 5 | # Status : Accepted (23218953) 6 | # Comment : 7 | 8 | 9 | P = int(input()) 10 | 11 | for p in range(P): 12 | a = 0 13 | b = 0 14 | c = 0 15 | N = int(input()) 16 | i = 1 17 | C = [0]*8 18 | for l in input(): 19 | a = b 20 | b = c 21 | c = 1 if l == 'H' else 0 22 | if i >= 3: 23 | C[(a << 2) + (b << 1) + c] += 1 24 | 25 | i += 1 26 | print(N, ' '.join(map(str, C)), '', sep=' ') 27 | -------------------------------------------------------------------------------- /SPOJ/OMWG_One more weird game/One more weird game.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: OMWG - One more weird game 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-17 4 | # Description : 5 | # Status : Accepted (23250636) 6 | # Comment : You can see on the grid as a grid graph where squares are vertices and neighboring squeres are edges. As it known the nxm grid graph has 2nm - n - m edges. 7 | 8 | f <- file('stdin', open='r') 9 | 10 | T = as.integer(readLines(f, n=1)) 11 | 12 | for (t in 1:T){ 13 | nm = unlist(strsplit(readLines(f, n=1), " ")) 14 | 15 | n = as.integer(nm[1]) 16 | m = as.integer(nm[2]) 17 | 18 | write(2*n*m - n - m, stdout()) 19 | } 20 | -------------------------------------------------------------------------------- /SPOJ/ORTL1P04 - Average/Average.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: ORTL1P04 - Average 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-04-02 4 | # Description : 5 | # Status : Accepted (23554130) 6 | # Tags : R 7 | # Comment : 100 score 8 | 9 | f <- file('stdin', open='r') 10 | 11 | tokens <- as.integer(unlist(strsplit(readLines(f, n=1), " "))) 12 | 13 | m <- mean(tokens) 14 | write(m, stdout()) 15 | if (m >= 6){ 16 | write("APROBADO", stdout()) 17 | } else { 18 | write("DESAPROBADO", stdout()) 19 | } 20 | -------------------------------------------------------------------------------- /SPOJ/P3EXLV1 - Somma tra due numeri/Somma tra due numeri.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: P3EXLV1 - Somma tra due numeri 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-28 5 | # Description : 6 | # Status : Accepted (23507945) 7 | # Tags : python 8 | # Comment : 9 | 10 | print(int(input()) + int(input())) 11 | -------------------------------------------------------------------------------- /SPOJ/P3LV0PRINT - Stringa maiuscola/Stringa maiuscola.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: P3LV0PRINT - Stringa maiuscola 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-28 4 | # Description : 5 | # Status : Accepted (23513331) 6 | # Tags : python 7 | # Comment : 8 | 9 | print(input().upper()) 10 | -------------------------------------------------------------------------------- /SPOJ/PARKET1_PARKET/PARKET1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: PARKET1 - Parkiet 3 | * Author : Wojciech Raszka 4 | * E-mail : gitpistachio@gmail.com 5 | * Date created : 2019-02-11 6 | * Description : 7 | * Status : Accepted (23212744) 8 | * Tags : java 9 | * Comment : Solve equation L*D = R + B and (l-2)*(D-2) = B 10 | */ 11 | 12 | import java.util.Scanner; 13 | import java.lang.Math; 14 | 15 | class PARKET1{ 16 | public static void main(String args[]){ 17 | Scanner sc = new Scanner(System.in); 18 | int R, B, L, D; 19 | int delta; 20 | 21 | R = sc.nextInt(); 22 | B = sc.nextInt(); 23 | 24 | delta = (R + 4)*(R + 4) - 16*(R + B); 25 | 26 | L = (int)(((R + 4) + Math.sqrt(delta))/4); 27 | D = (int)(((R + 4) - Math.sqrt(delta))/4); 28 | 29 | System.out.println(L + " " + D); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SPOJ/PGR01 - Progressions/Progressions.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: PGR01 - Progressions 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-31 4 | # Description : 5 | # Status : Accepted (23537738) 6 | # Tags : python, integer sequence A124647 (OEIS) 7 | # Comment : a(n) = (2n + 1)*3^n 8 | 9 | T = int(input()) 10 | 11 | for t in range(T): 12 | n = int(input()) - 1 13 | print((2*n + 1)*3**n) 14 | -------------------------------------------------------------------------------- /SPOJ/PLAYGAME_PLAYGAME/PLAYGAME.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: PLAYGAME - PLAYGAME 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-17 4 | # Description : 5 | # Status : Accepted (23250688) 6 | # Tags : python 7 | # Comment : f <=> g 8 | 9 | T = int(input()) 10 | 11 | def g(n): 12 | if n > 5: 13 | return not max(g(n - 1), g(n - 2), g(n - 5)) 14 | elif n == 1 or n == 2 or n == 4 or n == 5: 15 | return True 16 | else: 17 | return False 18 | 19 | def f(n): 20 | if n % 3 == 0: 21 | return False 22 | else: 23 | return True 24 | 25 | for t in range(T): 26 | if f(int(input())): 27 | print("Hemlata") 28 | else: 29 | print("Ragini") 30 | -------------------------------------------------------------------------------- /SPOJ/PRADIPSUM - Easy Math/PRADIPSUM.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: PRADIPSUM - Easy Math 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-06-13 5 | # Description : 6 | # Status : Accepted (23915222) 7 | # Tags : python, arithmetic progression 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | def sum_of_consecutive_numbers(a, b): 13 | if a > b: 14 | a, b = b, a 15 | 16 | return (a + b)/2*(b - a + 1) 17 | 18 | 19 | for tokens in stdin: 20 | a, b = tokens.split() 21 | a, b = int(a), int(b) 22 | 23 | stdout.write('%d\n' %sum_of_consecutive_numbers(a, b)) 24 | -------------------------------------------------------------------------------- /SPOJ/PRJAN15A - An Arithmetic Problem/An Arithmetic Problem.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: PRJAN15A - An Arithmetic Problem 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-06-06 7 | # Description : 8 | # Status : Accepted (23888670) 9 | # Tags : bash, arithmetic progression 10 | # Comment : 11 | 12 | read T 13 | for ((t = 1; t <= $T; t++)); do 14 | read a b c n 15 | 16 | if [ $(($c - $b - $b + $a)) -eq 0 ]; then 17 | echo "Case $t: " 18 | else 19 | echo "Case $t: Error" 20 | fi 21 | done 22 | -------------------------------------------------------------------------------- /SPOJ/QWERTY01 - How many words(SHELL)/How many words(SHELL).sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: QWERTY01 - How many words(SHELL) 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-03-24 7 | # Description : 8 | # Status : Accepted (23483578) 9 | # Tags : bash 10 | # Comment : 200 11 | 12 | read word_to_find 13 | 14 | no_of_equals=0 15 | read word 16 | while [ "$word" != "end" ] 17 | do 18 | if [ "$word" = "$word_to_find" ] 19 | then 20 | let no_of_equals=no_of_equals+1 21 | fi 22 | read word 23 | done 24 | 25 | echo $no_of_equals 26 | -------------------------------------------------------------------------------- /SPOJ/QWERTY01 - How many words(SHELL)/How many words(SHELL)_v2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: QWERTY01 - How many words(SHELL) 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-24 6 | # Description : 7 | # Status : 8 | # Tags : bash 9 | # Comment : 109 10 | 11 | read f 12 | 13 | n=0 14 | read w 15 | while [ "$w" != "end" ] 16 | do 17 | if [ "$w" = "$f" ] 18 | then 19 | let n=n+1 20 | fi 21 | read w 22 | done 23 | 24 | echo $n 25 | -------------------------------------------------------------------------------- /SPOJ/QWERTY01 - How many words(SHELL)/How many words(SHELL)_v3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: QWERTY01 - How many words(SHELL) 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-03-24 6 | # Description : 7 | # Status : Accepted (23483623) 8 | # Tags : bash 9 | # Comment : 22 10 | 11 | read w 12 | grep $w | wc -l 13 | -------------------------------------------------------------------------------- /SPOJ/QWERTY02 - BF writing/BF writing.bf: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: QWERTY02 - BF writing 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-29 5 | # Description : 6 | # Status : Accepted (23522855) 7 | # Tags : brainfuck 8 | # Comment : 155 chars 9 | 10 | 11 | +++++[>+++<-]>[>+++++>++>++>++<<<<-]>--.>++.>+++++[>++>+++>+++<<<-]>>+++.+++.+++++++.<+.<<.<-------.>>>>----.<----.>>.<----.>---.<<<<++++++++++..>>>>+++++. 12 | -------------------------------------------------------------------------------- /SPOJ/QWERTY03 - Java counting/QWERTY03.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: QWERTY03 - Java counting 3 | * Author : Wojciech Raszka 4 | * E-mail : gitpistachio@gmail.com 5 | * Date created : 2019-03-29 6 | * Description : 7 | * Status : Accepted (23522982) 8 | * Tags : java 9 | * Comment : 237 chars 10 | */ 11 | 12 | import java.util.*;class E{public static void main(String a[]){Scanner s=new Scanner(System.in);int n=s.nextInt()+1;int[] l=new int[256];while(n-->1)l[s.next().charAt(0)]++;for(;n<123;n++)if(l[n]>0)System.out.println((char)n+" "+l[n]);}} 13 | -------------------------------------------------------------------------------- /SPOJ/RETO2 - TIEMPO JUNTOS grado 10/TIEMPO JUNTOS grado 10.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: RETO2 - TIEMPO JUNTOS grado 10 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-26 5 | # Description : 6 | # Status : Accepted (23688932) 7 | # Tags : python 8 | # Comment : 9 | 10 | L1, R1, L2, R2, k = map(int, input().split()) 11 | 12 | if R1 < L2: 13 | print(0) 14 | elif L1 > R2: 15 | print(0) 16 | else: 17 | L = max(L1, L2) 18 | R = min(R1, R2) 19 | 20 | if L <= k <= R: 21 | print(R - L) 22 | else: 23 | print(R - L + 1) 24 | -------------------------------------------------------------------------------- /SPOJ/RREVERSE - Reverse/Reverse.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: RREVERSE - Reverse 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-14 5 | # Description : 6 | # Status : Accepted (23631652) 7 | # Tags : python 8 | # Comment : 9 | 10 | import sys 11 | 12 | for token in sys.stdin: 13 | print(int(token[::-1])) 14 | -------------------------------------------------------------------------------- /SPOJ/RUHUL2 - Simple Sum/Simple Sum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: RUHUL2 - Simple Sum 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-11-08 7 | # Description : 8 | # Status : Accepted (24808070) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read a b 13 | echo $(($a + $b)) 14 | -------------------------------------------------------------------------------- /SPOJ/S1P4 - Celebration/Celebration.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: S1P4 - Celebration 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-25 4 | # Description : 5 | # Status : Accepted (23489619) 6 | # Tags : python 7 | # Comment : 8 | 9 | tokens = raw_input().split() 10 | x = int(float(tokens[0])) 11 | A = x*7 12 | B = int(tokens[1])*int(tokens[1]) 13 | 14 | if (x + 1) % 2 == 0 and (A + B) <= 100: 15 | print 1 16 | else: 17 | print 0 18 | -------------------------------------------------------------------------------- /SPOJ/SBANK - Sorting Bank Accounts/Sorting Bank Accounts.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SBANK - Sorting Bank Accounts 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-15 4 | # Description : 5 | # Status : Accepted (23420647) 6 | # Comment : 7 | 8 | library(plyr) 9 | f <- file('stdin', open='r') 10 | 11 | T <- as.integer(readLines(f, n=1)) 12 | 13 | for (t in 1:T){ 14 | n <- as.integer(readLines(f, n=1)) 15 | bank_accounts <- readLines(f, n=n) 16 | dt <- count(bank_accounts) 17 | write.table(dt, file=stdout(), quote=FALSE, row.names=FALSE, col.names=FALSE, sep="") 18 | 19 | if (t < T){ 20 | write("", stdout()) 21 | readLines(f, n=1) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SPOJ/SBANK - Sorting Bank Accounts/Sorting Bank Accounts.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SBANK - Sorting Bank Accounts 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-15 4 | # Description : 5 | # Status : Accepted (23420527) 6 | # Tags : python, sorting, group by 7 | # Comment : O(nlogn) 8 | 9 | import sys 10 | from itertools import groupby 11 | 12 | T = int(sys.stdin.readline()) 13 | 14 | for t in range(T): 15 | n = int(sys.stdin.readline()) 16 | bank_accounts = sorted([sys.stdin.readline().rstrip() for i in range(n)]) 17 | sys.stdout.write('\n'.join([k + " " + str(len(list(g))) for k, g in groupby(bank_accounts)]) + "\n") 18 | 19 | if t + 1 < T: 20 | sys.stdout.write("\n") 21 | sys.stdin.readline() 22 | -------------------------------------------------------------------------------- /SPOJ/SCPC11B_Alaska/Alaska.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SCP11B Alaska 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-13 4 | # Description : 5 | # Status : Accepted (23225055) 6 | # Comment : 7 | 8 | n = int(input()) 9 | 10 | while n > 0: 11 | stations = [int(input()) for i in range(n)] 12 | 13 | if stations is None: 14 | print("IMPOSSIBLE") 15 | else: 16 | stations.sort() 17 | 18 | is_possible = True 19 | if stations[0] > 200: 20 | is_possible = False 21 | else: 22 | for i in range(1, n): 23 | if stations[i] - stations[i - 1] > 200: 24 | is_possible= False 25 | break 26 | else: 27 | if (1422 - stations[n - 1])*2 > 200: 28 | is_possible = False 29 | 30 | if is_possible: 31 | print("POSSIBLE") 32 | else: 33 | print("IMPOSSIBLE") 34 | 35 | n = int(input()) 36 | -------------------------------------------------------------------------------- /SPOJ/SEC01 - Join/Join.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SEC01 - Join 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-11-08 5 | # Description : 6 | # Status : Accepted (24807934) 7 | # Tags : python 8 | # Comment : 9 | 10 | from sys import stdin, stdout 11 | 12 | stdout.write('Joined For Practising Number Theory Ep-01\n') 13 | -------------------------------------------------------------------------------- /SPOJ/SEC01 - Join/Join.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: SEC01 - Join 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-11-08 7 | # Description : 8 | # Status : Accepted (24807941) 9 | # Tags : bash 10 | # Comment : 11 | 12 | echo "Joined For Practising Number Theory Ep-01" 13 | -------------------------------------------------------------------------------- /SPOJ/SILVER - Cut the Silver Bar/SILVER.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: SILVER - Cut the Silver Bar 3 | * Author : Wojciech Raszka 4 | * E-mail : gitpistachio@gmail.com 5 | * Date created : 2019-04-14 6 | * Description : 7 | * Status : Accepted (23631816) 8 | * Tags : java, integer sequence A000523 (OEIS), floor logarithm base 2 9 | * Comment : 10 | */ 11 | 12 | import java.util.Scanner; 13 | 14 | final class SILVER{ 15 | public static int floorLog2(int n){ 16 | if(n <= 0) throw new IllegalArgumentException(); 17 | return 31 - Integer.numberOfLeadingZeros(n); 18 | } 19 | 20 | public static void main(String args[]){ 21 | Scanner sc = new Scanner(System.in); 22 | int n; 23 | 24 | while ((n = sc.nextInt()) != 0){ 25 | System.out.println(floorLog2(n)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SPOJ/SIZECON - Size Contest/Size Contest.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: CRS - Crying Series 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-03-09 5 | # Description : 6 | # Status : Accepted (23531393) 7 | # Tags : python 8 | # Comment : 65 chars 9 | 10 | def p(x): 11 | x = int(input()) 12 | return x*(x > 0) 13 | 14 | print(sum(map(p, range(p(1))))) 15 | -------------------------------------------------------------------------------- /SPOJ/SMPCPH1 - Substitution cipher/Substitution cipher.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPCPH1 - Substitution cipher 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-02-24 5 | # Description : 6 | # Status : Accepted (23290652) 7 | # Tags : python, cryptography, substitution cipher 8 | # Comment : 9 | 10 | n = int(input()) 11 | #preparing substitution aplhabet 12 | cypher = input()[::-1] 13 | cypher_key = [] 14 | for i in range(n): 15 | cypher_key.append([cypher[i], cypher[i - 1]]) 16 | 17 | cypher_key[-1][0] = "|" 18 | m = int(input()) 19 | 20 | for i in range(m): 21 | s = input().replace(cypher_key[0][1], "|") 22 | for key, val in cypher_key: 23 | s = s.replace(key, val) 24 | print(s) 25 | -------------------------------------------------------------------------------- /SPOJ/SMPSEQ3 - Fun with Sequences/Fun with Sequences.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPSEQ3 - Fun with Sequences 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23291137) 6 | # Comment : 7 | 8 | n = int(input()) 9 | S = input().split() 10 | m = int(input()) 11 | Q = input().split() 12 | 13 | print(' '.join(filter(lambda s: not s in Q, S))) 14 | -------------------------------------------------------------------------------- /SPOJ/SMPSEQ4 - Fun with Sequences (Act 2)/Fun with Sequences (Act 2).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPSEQ4 - Fun with Sequences (Act 2) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23291152) 6 | # Comment : 7 | 8 | n = int(input()) 9 | S = input().split() 10 | m = int(input()) 11 | Q = input().split() 12 | 13 | print(' '.join(filter(lambda s: s in Q, S))) 14 | -------------------------------------------------------------------------------- /SPOJ/SMPSEQ5_Fun with Sequences (Act 3)/Fun with Sequences (Act 3).R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: Fun with Sequences (Act 3) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-11 4 | # Description : 5 | # Status : Accepted (23212628) 6 | # Comment : 7 | 8 | f <- file('stdin', open='r') 9 | 10 | n = as.integer(readLines(f, n=1)) 11 | 12 | S = unlist(strsplit(readLines(f, n=1), ' ')) 13 | 14 | m = as.integer(readLines(f, n=1)) 15 | 16 | Q = unlist(strsplit(readLines(f, n=1), ' ')) 17 | 18 | k = min(n, m) 19 | 20 | write(which(S[1:k] == Q[1:k]), stdout()) 21 | -------------------------------------------------------------------------------- /SPOJ/SMPSEQ6 - Fun with Sequences (Act 4)/Fun with Sequences (Act 4).R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPSEQ6 - Fun with Sequences (Act 4) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23291518) 6 | # Comment : 7 | 8 | f <- file('stdin', open='r') 9 | 10 | nx <- unlist(strsplit(readLines(f, n=1), ' ')) 11 | n = as.integer(nx[1]) 12 | x = as.integer(nx[2]) 13 | 14 | S <- unlist(strsplit(readLines(f, n=1), ' ')) 15 | Q <- unlist(strsplit(readLines(f, n=1), ' ')) 16 | 17 | SQ = c() 18 | for (i in 1:n){ 19 | for (j in max(1, i - x):min(n, i + x)){ 20 | if (S[i] == Q[j]){ 21 | SQ = c(SQ, i) 22 | break 23 | } 24 | } 25 | } 26 | 27 | cat(SQ, file=stdout(), fill=TRUE, sep=" ") 28 | -------------------------------------------------------------------------------- /SPOJ/SMPSEQ8 - Fun with Sequences (Act 6)/Fun with Sequences (Act 6).R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPSEQ8 - Fun with Sequences (Act 6) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23291876) 6 | # Comment : 7 | 8 | f <- file('stdin', open='r') 9 | 10 | n <- as.integer(readLines(f, n=1)) 11 | S <- as.integer(unlist(strsplit(readLines(f, n=1), ' '))) 12 | 13 | m <- as.integer(readLines(f, n=1)) 14 | Q <- as.integer(unlist(strsplit(readLines(f, n=1), ' '))) 15 | 16 | if (sum(S) > sum(Q)){ 17 | cat(S, file=stdout(), fill=TRUE, sep=" ") 18 | } else { 19 | cat(Q, file=stdout(), fill=TRUE, sep=" ") 20 | } 21 | -------------------------------------------------------------------------------- /SPOJ/SMPSEQ9 - Fun with Sequences (Act 7)/Fun with Sequences (Act 7).R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPSEQ9 - Fun with Sequences (Act 7) 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23291889) 6 | # Comment : 7 | 8 | f <- file('stdin', open='r') 9 | 10 | n <- as.integer(readLines(f, n=1)) 11 | S <- as.integer(unlist(strsplit(readLines(f, n=1), ' '))) 12 | 13 | m <- as.integer(readLines(f, n=1)) 14 | Q <- as.integer(unlist(strsplit(readLines(f, n=1), ' '))) 15 | 16 | if (sum(S)/n > sum(Q)/m){ 17 | cat(S, file=stdout(), fill=TRUE, sep=" ") 18 | } else { 19 | cat(Q, file=stdout(), fill=TRUE, sep=" ") 20 | } 21 | -------------------------------------------------------------------------------- /SPOJ/SMPSUM - Iterated sums/Iterated sums.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SMPSUM - Iterated sums 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23290219) 6 | # Comment : 7 | 8 | f <- file('stdin', open='r') 9 | 10 | l <- unlist(strsplit(readLines(f, n=1), " ")) 11 | a <- as.integer(l[1]) - 1 12 | b <- as.integer(l[2]) 13 | 14 | is <- (b*(b + 1)*(2*b + 1) - a*(a + 1)*(2*a + 1))/6 15 | 16 | write(is, stdout()) 17 | -------------------------------------------------------------------------------- /SPOJ/SMPWOW - Wow/Wow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: SMPWOW - Wow 4 | # Author : Wojciech Raszka 5 | # Date created : 2019-02-24 6 | # Description : 7 | # Status : Accepted (23289893) 8 | # Comment : 9 | 10 | read n 11 | 12 | Wow="W" 13 | 14 | for ((i=0; i<$n; i++)) 15 | do 16 | Wow="${Wow}o" 17 | done 18 | Wow="${Wow}w" 19 | 20 | echo $Wow 21 | -------------------------------------------------------------------------------- /SPOJ/SOD - Sum of Divisors/Sum of Divisors.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SOD - Sum of Divisors 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2021-03-12 5 | # Description : 6 | # Status : Accepted (27545878) 7 | # Tags : python, math, sum of divisors, prime factoriztion, prime numbers, geometric series 8 | # Comment : Sum of divisors sigma(n) = simga(p_1^k_1*p_2^k_2...p_i^k_i) = sigma(p_1^k_1)*sigma(p_2^k_2)*...*simga(p_i^k_i). Also sigma(p^k) = (p^(k - 1) - 1)/(p - 1) 9 | 10 | from sys import stdin, stdout 11 | 12 | no_of_prime_factors = int(stdin.readline()) 13 | 14 | sod = 1 15 | for _ in range(no_of_prime_factors): 16 | p, k = map(int, stdin.readline().split()) 17 | sod *= (p**(k + 1) - 1)//(p - 1) 18 | 19 | stdout.write('{}\n'.format(sod)) -------------------------------------------------------------------------------- /SPOJ/STRHH - Half of the half/STRHH - Half of the half.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: STRHH - Half of the half 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-24 4 | # Description : 5 | # Status : Accepted (23290176) 6 | # Comment : 7 | 8 | T = int(input()) 9 | 10 | for t in range(T): 11 | l = input() 12 | print(l[:len(l)//2:2]) 13 | -------------------------------------------------------------------------------- /SPOJ/SUCCESS - Success/Success.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: SUCCESS - Success 3 | * Author : Wojciech Raszka 4 | * E-mail : gitpistachio@gmail.com 5 | * Date created : 2019-04-09 6 | * Description : 7 | * Status : Accepted (23607478) 8 | * Tags : c 9 | * Comment : 24 characters 10 | */ 11 | 12 | main(){puts("Success");} 13 | -------------------------------------------------------------------------------- /SPOJ/SUCCESS - Success/Success_v2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: SUCCESS - Success 3 | * Author : Wojciech Raszka 4 | * E-mail : gitpistachio@gmail.com 5 | * Date created : 2019-04-09 6 | * Description : 7 | * Status : Accepted (23607897) 8 | * Tags : c 9 | * Comment : 21 characters 10 | */ 11 | 12 | main(){printf("%m");} 13 | -------------------------------------------------------------------------------- /SPOJ/SUMITR - Sums in a Triangle/Sums in a Triangle.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SUMITR - Sums in a Triangle 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-06-21 5 | # Description : 6 | # Status : Accepted (23592215) 7 | # Tags : python, dynamic programming, DP 8 | # Comment : 9 | 10 | def r(): 11 | return list(map(int,raw_input().split())) 12 | T=r()[0] 13 | while T>0: 14 | n=r()[0];P=[0]*100 15 | for i in range(n): 16 | C=r();x=0 17 | for j in range(1,i+2): 18 | P[j],x=C[j-1]+max(x,P[j]),P[j] 19 | print max(P) 20 | T-=1 21 | -------------------------------------------------------------------------------- /SPOJ/SUMLIS - Somma i numeri/Somma i numeri.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SUMLIS - Somma i numeri 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-28 4 | # Description : 5 | # Status : Accepted (23507972) 6 | # Tags : python 7 | # Comment : 8 | 9 | print(sum(eval(input()))) 10 | -------------------------------------------------------------------------------- /SPOJ/SUMTRIAN - Sums in a Triangle (tutorial)/Sums in a Triangle (tutorial).py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SUMTRIAN - Sums in a Triangle (tutorial) 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 2019-06-21 5 | # Description : 6 | # Status : Accepted (23955438) 7 | # Tags : python, dynamic programming, DP 8 | # Comment : 9 | 10 | T = int(raw_input()) 11 | while T > 0: 12 | n = int(raw_input()) 13 | P = [0]*(n + 1) 14 | 15 | for i in range(n): 16 | row = [int(val) for val in raw_input().split()] 17 | x = 0 18 | for j in range(i + 1): 19 | P[j + 1], x = row[j] + max(x, P[j + 1]), P[j + 1] 20 | 21 | print max(P) 22 | 23 | T-=1 24 | -------------------------------------------------------------------------------- /SPOJ/SUMUNZ - Sum Until 0/Sum Until 0.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: SUMUNZ - Sum Until 0 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-03-24 4 | # Description : 5 | # Status : Accepted (23483801) 6 | # Tags : python 7 | # Comment : 8 | 9 | A = eval(input()) 10 | try: 11 | idx = A.index(0) 12 | except: 13 | idx = -1 14 | 15 | if idx != -1: 16 | print(sum(A[:idx])) 17 | else: 18 | print(sum(A)) 19 | -------------------------------------------------------------------------------- /SPOJ/TAP2015H - Hugo s homework/Hugo s homework.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: TAP2015H - Hugo s homework 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-02-20 5 | # Description : 6 | # Status : Accepted (23268725) 7 | # Tags : python 8 | # Comment : 9 | 10 | def substraction(n): 11 | if n == 0: 12 | return 0 13 | else: 14 | return 1 + substraction(n - int(''.join(sorted(str(n))))) 15 | 16 | import sys 17 | 18 | for line in sys.stdin: 19 | n = int(line) 20 | print(substraction(n)) 21 | -------------------------------------------------------------------------------- /SPOJ/TAP2016A - Helping grandpa Laino/Helping grandpa Laino.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: Test 1 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-04-13 7 | # Description : 8 | # Status : Accepted (23629481) 9 | # Tags : bash 10 | # Comment : 11 | 12 | DONE=false 13 | until $DONE; do 14 | 15 | read item || DONE=true 16 | 17 | if [ $item != "" ]; then 18 | if [[ $item = *i* ]]; then 19 | echo N 20 | else 21 | echo S 22 | fi 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /SPOJ/TESTINT_Test 1/Test 1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: Test 1 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-02-03 7 | # Description : 8 | # Status : Accepted (???) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read a 13 | read b 14 | echo $((a + b)) 15 | -------------------------------------------------------------------------------- /SPOJ/TEST_Life, the Universe, and Everything/1_Life, the Universe, and Everything.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: TEST - Life, the Universe, and Everything 2 | # Author : Wojciech Raszka 3 | # Date created : 4 | # Description : 5 | # Status : Accepted (???) 6 | # Tags : R 7 | # Comment : 8 | 9 | f <- file('stdin', open='r') 10 | 11 | for(ans in readLines(f)){ 12 | if (ans == '42') break 13 | write(ans, stdout()) 14 | } 15 | -------------------------------------------------------------------------------- /SPOJ/TEST_Life, the Universe, and Everything/1_Life, the Universe, and Everything.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: TEST - Life, the Universe, and Everything 2 | # Author : Wojciech Raszka 3 | # E-mail : contact@gitpistachio.com 4 | # Date created : 5 | # Description : 6 | # Status : 7 | # Tags : python 8 | # Comment : 9 | 10 | while True: 11 | ans = input() 12 | if ans == '42': 13 | break 14 | print(ans) 15 | -------------------------------------------------------------------------------- /SPOJ/TEST_Life, the Universe, and Everything/1_Life, the Universe, and Everything.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: TEST - Life, the Universe, and Everything 4 | # Author : Wojciech Raszka 5 | # E-mail : contact@gitpistachio.com 6 | # Date created : 7 | # Description : 8 | # Status : 9 | # Tags : bash 10 | # Comment : 11 | 12 | while true 13 | do 14 | read line 15 | if [ $line -eq 42 ] 16 | then 17 | exit 0 18 | fi 19 | echo $line 20 | done 21 | -------------------------------------------------------------------------------- /SPOJ/TEST_Life, the Universe, and Everything/TEST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: TEST - Life, the Universe, and Everything 3 | * Author : Wojciech Raszka 4 | * Date created : 5 | * Description : 6 | * Status : 7 | * Comment : 8 | */ 9 | 10 | import java.util.Scanner; 11 | 12 | class TEST 13 | { 14 | public static void main(String[] args) 15 | { 16 | Scanner sc = new Scanner(System.in); 17 | int ans; 18 | do 19 | { 20 | ans = sc.nextInt(); 21 | if (ans == 42) break; 22 | System.out.println(ans); 23 | } while (true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SPOJ/THINK - Strange Pattern (Easy)/Strange Pattern (Easy).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: THINK - Strange Pattern (Easy) 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-03-30 5 | * Description : 6 | * Status : Accepted (23427021) 7 | * Tags : c++ 8 | * Comment : 9 | */ 10 | 11 | 12 | #include 13 | 14 | int count(int x){ 15 | 16 | return 2+x/2-(x-2)/2; 17 | 18 | } 19 | 20 | int main(){ 21 | 22 | for( int i=1 ; i-1001 ; i++ ) printf("%d %d\n",i,count(i)); 23 | 24 | return 0; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /SPOJ/THINKBIT - Strange Pattern (Medium)/Strange Pattern (Medium).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: THINKBIT - Strange Pattern (Medium) 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-03-30 5 | * Description : 6 | * Status : Accepted (23530958) 7 | * Tags : c++ 8 | * Comment : I think there is much more elegant solution 9 | */ 10 | 11 | 12 | 13 | #include 14 | 15 | int count(int x){ 16 | 17 | return x>>13&1|x>>12&1|x>>11&1|x>>10&1|x>>9&1|x>>8&1|x>>7&1|x>>6&1|x>>5&1|x>>4&1|x>>3&1|x>>2&1|x>>1&1|2; 18 | 19 | } 20 | 21 | int main(){for(int i=1;i^10001;i++)printf("%d %d\n",i,count(i));return 0;} 22 | -------------------------------------------------------------------------------- /SPOJ/THINKX - Strange Pattern (Hard)/Strange Pattern (Hard).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project name : SPOJ: THINKBIT - Strange Pattern (Medium) 3 | * Author : Wojciech Raszka 4 | * Date created : 2019-03-30 5 | * Description : 6 | * Status : Accepted (23531180) 7 | * Tags : c++ 8 | * Comment : 9 | */ 10 | 11 | 12 | #include 13 | 14 | int count(int x){ 15 | 16 | return x*x!=x|(~x0: 13 | n=r()[0];P=[0]*101;T-=1 14 | for i in range(n): 15 | C=r();x=0 16 | for j in range(1,i+2): 17 | P[j],x=C[j-1]+max(x,P[j]),P[j] 18 | print max(P) 19 | -------------------------------------------------------------------------------- /SPOJ/TSHOW1 - Amusing numbers/Amusing numbers.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: TSHOW1 - Amusing numbers 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-04-18 5 | # Description : 6 | # Status : Accepted (23654914) 7 | # Tags : python, number theory, integer sequence A256291 (OEIS) 8 | # Comment : 9 | 10 | def a(n): 11 | result = 0 12 | k = 2 13 | factor = 1 14 | while k - 2 <= n: 15 | if (n + 2) % k < (k >> 1): 16 | result += 5*factor 17 | else: 18 | result += 6*factor 19 | 20 | k = k << 1 21 | factor *= 10 22 | 23 | return result 24 | 25 | 26 | T = int(input()) 27 | 28 | while T > 0: 29 | n = int(input()) 30 | print(a(n - 1)) 31 | 32 | T -= 1 33 | -------------------------------------------------------------------------------- /SPOJ/TSMIVIOLET - Violet and Her Dream Land/Violet and Her Dream Land.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Project name : SPOJ: TSMIVIOLET - Violet and Her Dream Land 4 | # Author : Wojciech Raszka 5 | # E-mail : gitpistachio@gmail.com 6 | # Date created : 2019-04-15 7 | # Description : 8 | # Status : Accepted (23635481) 9 | # Tags : bash 10 | # Comment : 11 | 12 | read day_of_week 13 | 14 | if [ $day_of_week == Monday ]; then 15 | echo Macaroon 16 | elif [ $day_of_week == Tuesday ]; then 17 | echo Toffee 18 | elif [ $day_of_week == Wednesday ]; then 19 | echo Waffles 20 | elif [ $day_of_week == Thursday ]; then 21 | echo Taco 22 | elif [ $day_of_week == Friday ]; then 23 | echo "French Fries" 24 | elif [ $day_of_week == Saturday ]; then 25 | echo Sandwich 26 | else 27 | echo Soup 28 | fi 29 | -------------------------------------------------------------------------------- /SPOJ/UCV2013I_Tambourine/Tambourine.R: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: UCV2013I - Tambourine 2 | # Author : Wojciech Raszka 3 | # Date created : 2019-02-15 4 | # Description : 5 | # Status : Accepted (23238155) 6 | # Comment : R = r*sin(2*pi/(4*N)) 7 | 8 | options(digits=15) 9 | 10 | f <- file('stdin', open='r') 11 | 12 | p <- unlist(strsplit(readLines(f, n=1) , ' ')) 13 | 14 | r = as.numeric(p[1]) 15 | N = as.integer(p[2]) 16 | 17 | pi = 3.141592653589793238 18 | while (r != 0 || N != 0){ 19 | write(format(round(r/sin(pi/(2*N)), 2), nsmall=2), stdout()) 20 | p <- unlist(strsplit(readLines(f, n=1) , ' ')) 21 | r = as.numeric(p[1]) 22 | N = as.integer(p[2]) 23 | } 24 | -------------------------------------------------------------------------------- /SPOJ/VPL0_E - External Sequence/External Sequence_v2.py: -------------------------------------------------------------------------------- 1 | # Project name : SPOJ: VPL0_E - External Sequence 2 | # Author : Wojciech Raszka 3 | # E-mail : gitpistachio@gmail.com 4 | # Date created : 2019-05-12 5 | # Description : 6 | # Status : Accepted (23754842) 7 | # Tags : python, number theory, integer sequence A005150 (OEIS), look and say sequence 8 | # Comment : 173 9 | 10 | def a(n): 11 | if n < 1: 12 | return '1' 13 | t = '' 14 | f = 0 15 | l = '' 16 | for d in a(n - 1): 17 | if l != d: 18 | t += (str(f) + l)*min(1, f) 19 | f = 0 20 | f += 1 21 | l = d 22 | return t + str(f) + l 23 | for t in range(int(input())): 24 | print('Scenario #%d: %s' % (t + 1, a(int(input())))) 25 | --------------------------------------------------------------------------------