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 rot_left(num, count) | |
bin_string = num.to_s(2) | |
bin_string = ("0" * (32 - bin_string.length)) + bin_string | |
shifted_string = bin_string[0..(count-1)] | |
rotated_string = bin_string[count..31] + shifted_string | |
return rotated_string.to_i(2) | |
end | |
def lsb_32(num) | |
s = num.to_s(2) |
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
get "/rps/:play" do | |
rps_plays = ["rock", "paper", "scissors", "rock"] | |
#outcomes = ["You win.", "You lose!", "It's a tie."] | |
unless rps_plays.include?(params["play"]) | |
return "Try entering rock, paper, or scissors." | |
end | |
comp_play = rand(3) | |
user_play = rps_plays.find_index(params["play"]) |