Giter VIP home page Giter VIP logo

codeabbey_solutions's Introduction

CodeAbbey_Solutions

CodeAbbey problems and the solutions I made for them.

A list of all problems can be found here: http://www.codeabbey.com/index/task_list
My Code Abbey profile page can be found here: Link

Note: Solutions are a mixture of both Python 2.7 and 3.4; that being said the newer a solution the more likely it is to be in Python 3.4, likewise, any solution that is not specified at the top of the program within a comment in likely in Python 2.7

Table of Contents:

  • CodeAbbey Problem 001 - Sum "A+B" [Completed in: Python]
  • CodeAbbey Problem 002 - Sum in Loop [Completed in: Python]
  • CodeAbbey Problem 003 - Sums in Loops [Completed in: Python]
  • CodeAbbey Problem 004 - Minimum of Two [Completed in: Python]
  • CodeAbbey Problem 005 - Minimum of Three [Completed in: Python]
  • CodeAbbey Problem 006 - Rounding [Completed in: Python]
  • CodeAbbey Problem 007 - Fahrenheit to Celsius [Completed in: Python]
  • CodeAbbey Problem 008 - Arithmetic Progression [Completed in: Python]
  • CodeAbbey Problem 009 - Triangles [Completed in: Python]
  • CodeAbbey Problem 010 - Linear Function [Completed in Python]
  • CodeAbbey Problem 011 - Sum of digits [Completed in: Python]
  • CodeAbbey Problem 012 - Modulo and time difference [Completed in: Python]
  • CodeAbbey Problem 013 - Weighted sum of digits [Completed in: Python]
  • CodeAbbey Problem 014 - Modular Calculator [Completed in: Python]
  • CodeAbbey Problem 015 - Maximum of array [Completed in: Python]
  • CodeAbbey Problem 016 - Average of an array [Completed in: Python]
  • CodeAbbey Problem 017 - Array Checksum [Completed in: Python]
  • CodeAbbey Problem 018 - Square Root [Completed in: Python]
  • CodeAbbey Problem 019 - Matching Brackets [Completed in: Python]
  • CodeAbbey Problem 020 - Vowel Count [Completed in: Python]
  • CodeAbbey Problem 021 - Array Counters [Completed in: Python]
  • CodeAbbey Problem 022 - Two Printers [Completed in: Python]
  • CodeAbbey Problem 023 - Bubble in Array [Completed in: Python]
  • CodeAbbey Problem 024 - Neumann's Random Generator [Completed in: Python]
  • CodeAbbey Problem 025 - Linear Congruential Generator [Completed in: Python]
  • CodeAbbey Problem 026 - GCD and LCM [Completed in: Python]
  • CodeAbbey Problem 027 - Bubble Sort [Completed in: Python]
  • CodeAbbey Problem 028 - Body Mass Index [Completed in: Python]
  • CodeAbbey Problem 029 - Sort with Indexes [Completed in: Python]
  • CodeAbbey Problem 030 - Reverse String [Completed in: Python]
  • CodeAbbey Problem 031 - Rotate String [Completed in: Python]
  • CodeAbbey Problem 032 - Josephus Problem [Completed in: Python]
  • CodeAbbey Problem 035 - Savings Calculator [Completed in: Python]
  • CodeAbbey Problem 037 - Mortgage Calculator [Completed in: Python]
  • CodeAbbey Problem 041 - Median of Three [Completed in: Python]
  • CodeAbbey Problem 042 - Blackjack Counting [Completed in: Python]
  • CodeAbbey Problem 043 - Dice Rolling [Completed in: Python]
  • CodeAbbey Problem 044 - Double Dice Roll [Completed in: Python]
  • CodeAbbey Problem 046 - Tic-Tac-Toe [Completed in: Python]
  • CodeAbbey Problem 047 - Caesar Shift Cipher [Completed in: Python]
  • CodeAbbey Problem 048 - Collatz Sequence [Completed in: Python]
  • CodeAbbey Problem 049 - Rock Paper Scissors [Completed in: Python]
  • CodeAbbey Problem 050 - Palindromes [Completed in: Python]
  • CodeAbbey Problem 052 - Pythagorean Theorem [Completed in: Python]
  • CodeAbbey Problem 054 - Card Names [Completed in: Python]
  • CodeAbbey Problem 055 - Matching Words [Completed in: Python]
  • CodeAbbey Problem 057 - Smoothing the Weather [Completed in: Python]
  • CodeAbbey Problem 059 - Bulls and Crows [Completed in: Python]
  • CodeAbbey Problem 061 - Prime Numbers Generation [Completed in: Python]
  • CodeAbbey Problem 062 - Prime Ranges [Completed in: Python]
  • CodeAbbey Problem 067 - Fibonacci Sequence [Completed in: Python]
  • CodeAbbey Problem 068 - Bicycle Race [Completed in: Python]
  • CodeAbbey Problem 069 - Fibonacci Divisibility [Completed in: Python]
  • CodeAbbey Problem 071 - Fibonacci Divisibility Advanced [Completed in: Python]
  • CodeAbbey Problem 075 - Yacht or Dice Poker [Completed in: Python]
  • CodeAbbey Problem 081 - Bit Count [Completed in: Python]
  • CodeAbbey Problem 094 - Fool's Day 2014 [Completed in: Python]
  • CodeAbbey Problem 104 - Triangle Area [Completed in: Python]
  • CodeAbbey Problem 114 - Tricky Printing [Completed in: Brainfuck]
  • CodeAbbey Problem 127 - Anagrams [Completed in: Python]
  • CodeAbbey Problem 128 - Combinations Counting [Completed in: Python]
  • CodeAbbey Problem 135 - Variable Length Code [Completed in: Python]
  • CodeAbbey Problem 157 - Emirp primE [Completed in: Python]

Problem descriptions:

Problem 1: Sum "A+B"
You are to add two numbers and tell their sum.
Solution

Problem 2: Sum in Loop
You are to find sum of several numbers (more than two).
Solution

Problem 3: Sums in Loops
You will be given several pairs of values and you need to calculate sum for each pair.
Solution

Problem 4: Minimum of Two
Of two numbers, please, select one with minimum value.
Solution

Problem 5: Minimum of Three
Several triplets of numbers are given to you. Your task is to select minimum among each of triplets.
Solution

Problem 6: Rounding
There are several pairs of numbers. For each pair you are to divide first by second and return the result, rounded to nearest integer. In cases, when result contains exactly 0.5 as a fraction part, value should be rounded up.
Solution

Problem 7: Fahrenheit to Celsius
You are to write program to convert degrees of Fahrenheit to Celsius.
Solution

Problem 8: Arithmetic Progression
Calculate sums of arithmetic progression.
Solution

Problem 9: Triangles
You are given several triplets of values representing lengths of the sides of triangles. You should tell from which triplets it is possible to build triangle and for which it is not.
Solution

Problem 10: Linear Function
Your task is to determine a and b by two points, belonging to the function. I.e. you are told two pairs of values (x1, y1), (x2, y2) which satisfy the function equation - and you should restore the equation itself.
Solution

Problem 11: Sum of digits
Find the sum of (A*B) + C and then find the sum of that sum's digits for each line.
Solution

Problem 12: Modulo and time difference
Calculate the difference in days, hours, minutes, and seconds between two times.
Solution

Problem 13: Weighted sum of digits
Calculate the weighted sum of digits.
Solution

Problem 14: Modular Calculator
Find the remainder of the result of all operations applied sequentially (starting with initial number) divided by the last number.
Solution

Problem 15: Maximum of array
Input data will give you exactly 300 numbers in a single line. Answer should contain maximum and minimum of these values, separated by space.
Solution

Problem 16: Average of an array
You will be given several arrays, for each of which you are to find an average value. 0s do not count. All answers rounded.
Solution

Problem 17: Array Checksum
Calculate the checksum for an array.
Solution

Problem 18: Square Root
Write a program using Heron's method to generate square roots within at least 1e-7 = 0.0000001 of accurancy.
Solution

Problem 19: Matching Brackets
Check a series of strings and return for each string if all brackets within have been used in the correct sequence.
Solution

Problem 20: Vowel Count
You will be given several lines of text - and for each of them you should tell the number of vowels (i.e. letters a, o, u, i, e, y). Note: that y is regarded as vowel for purpose of this task.
Solution

Problem 21: Array Counters
Here is an array of length M with numbers in the range 1 ... N, where N is less than or equal to 20. You are to go through it and count how many times each number is encountered.
Solution

Problem 22: Two Printers
Using two printers working together that print at different speeds, determine the shortest amount of time required to print a document. Note: All pages have to be completely printed. 2 printers printing at 1 page per second make 5 pages in 3 seconds, not 2.5 seconds.
Solution

Problem 23: Bubble in Array
Swap values in an array of numbers so that if a number is greater than the one before it their places are switched. Then display the amount of swaps made and the checksum of the final solution.
Solution

Problem 24: Neumann's Random Generator
You will be given initial numbers for several sequences. For each of them report the number of iterations needed to come to repetition using Neumann's Random Generator.
Solution

Problem 25: Linear Congruential Generator
Generate the Nth number for each set of input ran through the Linear Congruential Generator.
Solution

Problem 26: GCD and LCM
Find the least common multiplier and greater common divisor for every pair of numbers.
Solution

Problem 27: Bubble Sort
Use the bubble sort method, then calculate the number of swaps and passes used in the sorting.
Solution

Problem 28: Body Mass Index
Calculate BMI multiple BMI values and assign whether they are under, normal, over, or obese BMIs.
Solution

Problem 29: Sort with Indexes
Sort a given array of numbers and then for each value (in non-decreasing order) its initial index should be printed.
Solution

Problem 30: Reverse String
Reverse the string of text.
Solution

Problem 31: Rotate String
Rotate string by K characters means to cut these characters from the beginning and transfer them to the end. If K is negative, characters, on contrary should be transferred from the end to the beginning.
Solution

Problem 32: Josephus Problem
Calculate who will be the survivor given the amount of participants and the dividing factor chosen for the Josephus problem.
Solution

Problem 35: Savings Calculator
Calculate how many years it will take to reach each monetary goal using a start amount, end amount, and interest rate.
Solution

Problem 37: Mortgage Calculator
Calculate the monthly payment for a mortgage.
Solution

Problem 41: Median of Three
Find the median number of each set of three numbers.
Solution

Problem 42: Blackjack Counting
Determine the best value of each Blackjack hand.
Solution

Problem 43: Dice Rolling
Convert values with floating point to one of six integer numbers: from 1 to 6.
Solution

Problem 44: Double Dice Roll
Convert dice roll values of 0 to 2,000,000,000 to the 1-6 range and then add them together.
Solution

Problem 46: Tic-Tac-Toe
Determine the winning turn in each game of Tic-Tac-Toe (or if it resulted in a draw)
Solution

Problem 47: Ceasar Shift Cipher
Decrypt the set of messages with a Caesar shift cipher. (I also added an encrypt option for fun.)
Solution

Problem 48: Collatz Sequence
Run each number through the Collatz Sequence and determine how many times it must be processed before it reaches the number "1".
Solution

Problem 49: Rock Paper Scissors
You will be given several records of played R.P.S. games. You are to tell for each of them who of players won. Note: They specified there would be no ties so I didn't add in a "tie game" ending.
Solution

Problem 50: Palindromes
Your goal in this programming exercise is to determine, whether the phrase represents a palindrome or not. Note: Spaces, capitalization, and punctuations are to be ignored.
Solution

Problem 52: Pythagorean Theorem
Determine if each triangle is right, acute, or obtuse.
Solution

Problem 54: Card Names
Use a number to determine the suit and name of each card.
Solution

Problem 55: Matching Words
Sort through hundreds of words and print out the list of repeated words in alphabetical order.
Solution

Problem 57: Smoothing the Weather
Return a list of temperatures by replacing each value with the average of it and the two beside it to provide a smooth final report.
Solution

Problem 59: Bulls and Crows
Record the number of exactly matching (number and position) numbers and numbers that are correct but in the wrong position and then return the amounts for each number in the data set.
Solution

Problem 61: Prime Numbers Generation
Generate an array of prime numbers and then find the nth prime numbers of given numbers. EX: 7 1 199999 4 input should return the output: 17 2 2750131 7
Solution

Problem 62: Prime Ranges
Count the amount of prime numbers within the range of each pair of 7-digit numbers given.
Solution

Problem 67: Fibonacci Sequence
You will be given several Fibonacci numbers. Your task is to tell their indices in the sequence.
Solution

Problem 68: Bicycle Race
You will be given the distance between cities S (in kilometers) and speed values for two bicyclists (A and B in kilometers per hour). Your task is to find their meeting point (its distance from the first of cities).
Solution

Problem 69: Fibonacci Divisibility
Find the index of the first non-zero member of this list, which is evenly divisible by this M, e.g. if you are given M = 17 the answer is 9 (the index of the element 34.) For all numbers given.
Solution

Problem 71: Fibonacci Divisibility Advanced
Find the index of the first non-zero member of this list, which is evenly divisible by this M, e.g. if you are given M = 17 the answer is 9 (the index of the element 34.) For all numbers given. The difference from the problem #69 is that the numbers inputted into this program are around 8 figures while problem #69 was around 1-2 figures.
Solution

Problem 75: Yacht or Dice Poker
Given the combination of dice determine what poker values (ex: pair or full-house) the dice contain.
Solution

Problem 81: Bit Count
Count the amount of non-zero bits in all given values.
Solution

Problem 94: Fool's Day 2014
Create the solving algorithm with only a set of test data. (No problem description)
Solution

Problem 104: Triangle Area
Find the area of all triangles only using the vertices.
Solution

Problem 114: Tricky Printing
Print the assigned number in Brainfuck.
Solution

Problem 127: Anagrams
Find all anagrams in the dictionary file given for each word.
Solution

Problem 128: Combinations Counting
Find the amount of possible combinations with all test cases.
Solution

Problem 135: Variable Length Code
Convert a string into assigned values and then encode by converting it then into hex.
Solution

Problem 157: Emirp primE
Find the closest larger prime number to each given input where the prime number will remain a prime number even if it is reversed.
Solution

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.