GithubHelp home page GithubHelp logo

cmrudolph / kattis Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.38 MB

Solutions to problems from https://open.kattis.com (just for fun and to play with languages)

License: MIT License

Python 64.81% C++ 3.67% C 12.04% Go 5.94% Roff 0.10% F# 13.45%

kattis's Introduction

10 Kinds of People | C | Problem | Solution
Use a queue and iterative search to identify which cells are connected to each other. A recursive solution is problematic because it can overflow the stack given the right inputs. Once we have tagged contiguous sections of like cells we are prepared to give answers to connectivity questions.

10 Kinds of People | Python | Problem | Solution
Use a queue and iterative search to identify which cells are connected to each other. A recursive solution is problematic because it can overflow the stack given the right inputs. Once we have tagged contiguous sections of like cells we are prepared to give answers to connectivity questions. This is the same as the solution implemented in C, but the Python version runs too slowly.

A Different Problem | F# | Problem | Solution
Test problem to get F# environment working

ACM Contest Scoring | Python | Problem | Solution
Simple problem with no significant performance requirements.

ASCII Addition | F# | Problem | Solution
Not a difficult problem to understand. Lots of array extraction and transformation. First "real" problem done in F#, so language learning curve applied.

ASCII Figure Rotation | Python | Problem | Solution
Straightforward 2D array manipulation problem where we must adjust both coordinates and values by applying a 90 degree rotation to the source values.

Adding Words | Python | Problem | Solution
Use dictionaries to provide a two-way lookup (values by terms and terms by values). Each of the three instructions is handled per the rules of the problem.

All Different Directions | Python | Problem | Solution
Read distances and angles and use basic trig to calculate destinations. Average the destinations once all inputs have been processed.

Almost Perfect | Go | Problem | Solution
Compute all factor pairs of the specified value using a division test. The factors are then summed and compared to the original value to determine which conclusion is most relevant (exact, almost, none).

Anagram Counting | Python | Problem | Solution
Calculate the total as n! / (n1!n2!...nk!) where the denominator is the product of the factorials of the number of occurrences of each distinct character in the input sequence.

Babylonian Numbers | F# | Problem | Solution
Problem involving the interpretation of a string representing a base 60 number. The value is given as a series of separated components in the 0-59 range and the expectation is that we produce the equivalent base 10 value.

Balanced Diet | C | Problem | Solution
Use recursion to figure out all the possible sums we can encounter by combining values in all possible ways. Without any optimizations this solution is O(2N). However, the problem is conducive to dynamic programming since once a subproblem has been solved we can save the result leverage it to avoid redundant work.

Batter Up | Python | Problem | Solution
Use a list comprehension to map strings to integers then do simple math on the list.

Bit by Bit | Go | Problem | Solution
Read and process each instruction, modifying the bits as we go.

CD | C++ | Problem | Solution
Simple solution involving walking both arrays simultaneously and looking for distinct/duplicates along the way. Chose C++ over Python because the latter was too slow.

CD | Python | Problem | Solution
Simple solution involving walking both arrays simultaneously and looking for distinct/duplicates along the way. Python is too slow on official machines.

Calculator | Python | Problem | Solution
Leverage Python's eval function to make this simple.

Counting Stars | Python | Problem | Solution
Similar problem to amoebas, but recursion grew the stack too much. Using iteration with a queue to visit and tag cells instead.

DRM Messages | Python | Problem | Solution
Straightforward application of the string manipulation rules. No performance constraints, so Python is adequate.

Dance Recital | C++ | Problem | Solution
Brute forcing all permutations is viable because N is small enough. Chose C++ over Python because the latter was too slow.

Dance Recital | Python | Problem | Solution
Brute forcing all permutations is viable because N is small enough. Python is too slow on official machines.

Eb Alto Saxophone Player | Python | Problem | Solution
Simple problem.

Engineering English | Go | Problem | Solution
Iterate over the strings in the input and use a map to store values we have seen before. A value's existence in the map means we need to replace it with our token value.

FBI Universal Control Numbers | F# | Problem | Solution
Problem involving string parsing, character substitutions, conversion between base 10 and base 27, computation and validation of a 'check digit', and then printing results for valid strings.

Foosball Dynasty | Python | Problem | Solution
Problem has no performance requirements, so Python is fine. Work through the rules, maintaining state properly as we go.

Game of Throwns | Python | Problem | Solution
Simple problem.

Hello World! | Python | Problem | Solution
Impossible to mess this one up...

Hidden Password | Python | Problem | Solution
Simple problem.

Inverse Factorial | C | Problem | Solution
Special case the first few factorial cases. After that use logs and take advantage of the fact we can identify the answer based on the number of digits in the factorial string.

Inverse Factorial - Long Division | C | Problem | Solution
Use repeated long division. While conceptually sound, this approach is computationally expensive and runs for too long on official judging machines.

Line Them Up | Python | Problem | Solution
Simple problem.

Lost in Translation | Python | Problem | Solution
Interesting graph problem. We traverse the graph using recursion to compute all our costs and then sum them up to determine the overall min.

Parsing Hex | Python | Problem | Solution
Extract hex strings using a regex.

Passing Secrets | Python | Problem | Solution
Undirected, weighted graph problem where we want the shortest route between two specific nodes. Start by building the graph representation of the problem domain based on the inputs. Then apply Dijkstra's algorithm to identify the shortest paths from the starting node to everything else. Finally consult the search results to retrace our steps to get to the end node optimally.

Permutation Encryption | Go | Problem | Solution
Iterate over the string to 'encrypt' while repeatedly looping over the key string. The key string drives character selection as we build up the result.

Phone List | Python | Problem | Solution
Simple problem.

Planina | Python | Problem | Solution
Simple problem.

Printing Costs | F# | Problem | Solution
String problem involving a char-int conversion and aggregation of the total cost of the string. Pattern matching with hard-coded costs is a simple way to specify the problem rules.

Rain Fall | Python | Problem | Solution
Interesting problem where we piece together the formula, then run a guess through it, compare, and refine the guess. Repeating this enough times gets us to right value for our unknown.

Red Rover | Python | Problem | Solution
Simple problem.

Reversed Binary Numbers | F# | Problem | Solution
Simple problem to apply basic concepts of F#. Solution involves simple string/integer conversions and string manipulation, lending itself to a set of simple functions chained together in a pipeline.

Running MoM | Python | Problem | Solution
Weighted graph problem where DFS can be used to identify cycles and the cycles serve as the basis for identifying "safe" cities in the analysis.

Sheba's Amoebas | Python | Problem | Solution
Work through the search space using recursion, tagging cells along the way. In principle, recursion can overflow the stack in these types of problems, but the search space here is sufficiently small that it is okay.

Soft Passwords | F# | Problem | Solution
Problem where a given input string needs to be compared with N other derived strings to see whether any of them match. All possible valid matches are derived so a simple "list contains" search can be done

The Calculus of Ada | Python | Problem | Solution
Simple recursive implementation with no significant performance requirements.

The Key to Cryptography | Python | Problem | Solution
Straightforward application of the string manipulation rules. No performance constraints, so Python is adequate.

Watersheds | Python | Problem | Solution
Graph problem based on a 2D array concept. Cells are conditionally connected based on rules (relationships simulating height differences), which produce sets of distinct drainage basins. Said basins need to be identified and labeled. Solved by defining the graph using adjacency lists, then traversing and labeling contiguous sections.

What does the fox say? | Python | Problem | Solution
Simple problem.

kattis's People

Contributors

cmrudolph avatar

Watchers

 avatar

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.