This file contains hidden or 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 capalize(word): - | |
| # a = word[0:1] - | |
| # a = a.upper - | |
| # b = word[1:] - | |
| # word = a + b - | |
| # return word - | |
| # - | |
| #print caplize(hello)- | |
| #--------------------- |
This file contains hidden or 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
| # pythagorean theorem | |
| from math import sqrt | |
| def pory(a,b,c): | |
| asquare = a*a | |
| bsquare = b*b | |
| c = asquare + bsquare | |
| c = sqrt(c) | |
| print "Solving the Pythagorean Theorem for "+a+" and "+b+" is "+c+"" | |
This file contains hidden or 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 fahrenheit_to_celsius(a): | |
| new_temp = (a - 32) * 5/9 | |
| new_temp = float(new_temp) | |
| print "{0} Fahrenheit converted to Celsius is {1}.".format(a, new_temp) | |
| def celsius_to_fahrenheit(a): | |
| new_temp = a * 9/5 + 32 | |
| new_temp = float(new_temp) | |
| print "{0} Celsius converted to Fahrenheit is {1}.".format(a, new_temp) | |
This file contains hidden or 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
| from math import sin, cos, tan | |
| #Work on Another Day. | |
| def triangle_side_finder(): | |
| x = 0 | |
| answer = None | |
| numbers = True | |
| degree = input("What is the degree of the angle?") | |
| while numbers == True: | |
| try: | |
| degree = int(degree) |
This file contains hidden or 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
| import java.util.Calendar; | |
| import java.util.GregorianCalendar; | |
| public class day { | |
| public static void main (String[] args) { | |
| Calendar calendar = new GregorianCalendar(); | |
| int day = calendar.get(Calendar.DAY_OF_WEEK); | |
| switch (day) { | |
| case 1: | |
| System.out.println("It\'s Sunday!"); |
This file contains hidden or 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
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.println("Hello, World.") | |
| } |
This file contains hidden or 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 authenticate | |
| authenticate_or_request_with_http_basic do |user, pass| | |
| Admin.find_by(user: user).try(:authenticate, pass) | |
| end | |
| end |
This file contains hidden or 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 create | |
| admin = Admin.find_by(user: params[:user]) | |
| if admin && admin.authenticate(params[:password]) != false | |
| login admin | |
| redirect_to root_path | |
| else | |
| redirect_to blog_index_path | |
| end | |
| end |
This file contains hidden or 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
| let 2+2=5 in 2+2 |
This file contains hidden or 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
| --not mine, from http://www.codewars.com/kata/hamming-distance/solutions?show-solutions=1 by mtthw123 | |
| module Hamming where | |
| hamming :: String -> String -> Int | |
| hamming a b = length . filter id $ zipWith (/=) a b |
OlderNewer