Giter Site home page Giter Site logo

code-katas's Introduction

code-katas

CodeFellows 401, Codewars.com Katas

forbes

This branch contains a solution for the the Forbes Top 40 Billionaires Kata.

The goal of this assignment is to:

Write a function that, returns the name, net worth, and industry of the **oldest billionaire under 80 years old** AND the youngest billionaire with a valid age. * Oldest under 80, not including 80. * You may not use a sorting function. * You may not use any external library (you don’t need it).

Stretch Goals:

Write another function that takes the company owned by the oldest under 80 and youngest billionaire and scrapes the web for its current stock price. If the company is not public, have an appropriate message. If the company is not an actual company, have an appropriate message.

I solved this kata by using the Binary Heap data structure. I loaded every billionaire with an age greater than 0 and less than 80 into it by age. The first one popped from the list was the youngest and the last one popped was the oldest.

The Heap used here is mine from the Data Structures assignments and I included its tests as well.

Cited Sources and Resources:

I made good use of http://jsonlint.com/ to find the JSON error in the supplied file, and to setup my test data without errors.

flight-paths

This branch is an attempt at solving the Flight-Paths kata.

Graph implementation by Justin, from here: https://github.com/welliam/data-structures/blob/master/src/graph.py

The goal of this assignment is to:

Write a function that,

given a starting city and an ending city, will return a path between the two cities (including the two cities).
also returns the total distance traveled between cities.
appropriately handles the situation where no path exists.

Stretch Goals:

Try to incorporate any (or all) of these. They are/can be independent of each other.

Add to your function a parameter that makes it return the shortest path (lowest distance) between the two cities.
Add to your function a parameter that makes it return the path with the fewest stops between the two cities.
Have your function take a parameter for a limit to the distance between any two cities. If specified, your function returns a path where each city-to-city jump is less than or equal to that limit.

I made an attempt at sovling this one and wasn't very successful, my comments are in the flight_paths.py file.

sort_cards

This branch represents a solution to the Codewars.com card sorting kata found here:

https://www.codewars.com/kata/sort-deck-of-cards/python

Directly quoted from the above link:

Description:

Write a function sort_cards() that sorts a shuffled list of cards, so that any given list of cards is sorted by rank, no matter the starting collection.

All cards in the list are represented as strings, so that sorted list of cards looks like this:

['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']

Example:

>>> sort_cards(['3', '9', 'A', '5', 'T', '8', '2', '4', 'Q', '7', 'J', '6', 'K'])
['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
Hint: Tests will have many occurrences of same rank cards, as well as vary in length. You can assume though, that input list is always going to have at least 1 element.

Sources used to complete this kata: https://wiki.python.org/moin/HowTo/Sorting, specifically the "Operator Module Functions" section.

code-katas's People

Contributors

derekmhewitt avatar

Watchers

James Cloos avatar  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.