This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
This code is meant to accompany the guide originally published at https://colby.so/posts/building-a-horizontal-slider-with-stimulus-and-tailwind | |
It intentionally pulls in Tailwind CSS and Stimulus without a build system to simplify the guide. You shouldn't do this with a real application, | |
you should use a build system like webpack! | |
--> | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
ruby '2.1.0' | |
gem 'rspec', '~> 2.14.0' | |
gem 'capybara' | |
gem 'pry-debugger', '~> 0.2.2' | |
gem 'sinatra' | |
gem 'sinatra-contrib' # Not required | |
gem 'thin' # Not required | |
gem 'rack-test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_biggest_triple(perimeter) | |
all_triples = [] # Empty array to hold all of the triplets | |
max_side_length = perimeter/2 # This isn't necessary because we filter but the method runs a lot faster if we cut down how many times the all_triples loops need to run. a + b should always be greater than c so no need to build triples that won't be selected | |
# Run outer loop perimeter/2 times - This is our hypotenuse | |
max_side_length.times do |a| | |
a.times do |b| | |
b.times do |c| | |
# Pythagorean triplet is found if the square of the two shorter sides (the two interior loops) equals the square of the hypotenuse | |
if c**2 + b**2 == a**2 |