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
| require 'net/http' | |
| #$IP = '172.16.180.128' | |
| # $IP = '192.168.125.129' | |
| $IP = '172.16.18.230' | |
| $PORT = '8080' | |
| $OBJECTS_API = 'api/sector/%d/objects' | |
| $ROOTS_API = 'api/sector/%d/roots' | |
| def get_request link |
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
| # You are given a template for an expression with parantheses. | |
| # For every template, print all possible valid parantheses expressions. | |
| def solution template, index, balance | |
| if balance < 0 | |
| return | |
| end | |
| # handles ? as last character in template | |
| if index >= template.length |
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
| # Gosho is a bunny. He lives in a forest full of hills. | |
| # Every hill has a different height and has a different amount of grass on it. | |
| # He likes jumping very much, but he only jumps in zig-zag manner. | |
| # I.e., he only jumps on a lower hill, then on an upper hill, then on a lower one again, | |
| # or he jumps on an upper hill, then on a lower one, then on an upper one again, and so on. | |
| # Gosho likes eating. He likes eating even more than he likes jumping. | |
| # You like Gosho and you want to help him. | |
| # On the first line of input you get the number N - the number of hills in the vicinity of Gosho. | |
| # On the next N lines, you get the pair P,Q, |
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
| # Remove every subsequence of K elements with the same value. | |
| # 1 1 1 2 3 3 4 5 | |
| # 2 | |
| # Output: 1 2 4 5 | |
| sequence = $stdin.readline.chomp.split.map { |i| i.to_i } | |
| k = $stdin.gets.chomp.to_i | |
| last_digit = sequence[0] | |
| count = 1 |
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
| # You are driving a car. | |
| # You start moving with a velocity of V1 meters per second. | |
| # Every second you can change your velocity with D meters per second. | |
| # After T seconds, you want to be driving with a velocity of V2. | |
| # What is the maximum distance you can travel during those T seconds? | |
| # 5 | |
| # 6 | |
| # 4 | |
| # 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
| # 4xN wall | |
| # Infinite supply of 1x4 and 4x1 bricks | |
| # M - total number of ways in which the bricks can be arranged on the wall | |
| # P - answer - number of prime numbers up to M | |
| # Input | |
| # T - integer | |
| # T lines of one integer | |
| # Output |
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
| # Given a time, calculate the angle between the hour and minute hands on a clock. | |
| hour = 3 | |
| minutes = 27 | |
| def solution(hour, minutes): | |
| minute_percentage = float(minutes) / 60 | |
| minute_degrees = minute_percentage * 360 | |
| hour_degrees = float(hour)/12 * 360 | |
| next_hour = (hour + 1) % 12 |
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
| # You are given a sorted array of integers. | |
| # Every element appears twice consequently, except for one. | |
| # Find the non-repeating element in O(log n). | |
| def f(list, start, end): | |
| mid = (start+end) / 2 | |
| # Two elements left | |
| if end-start <= 1: | |
| prev = list[start-1] |
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
| SELECT | |
| COUNT(*) | |
| FROM | |
| ( | |
| SELECT | |
| clubs.club_name, kids.name | |
| FROM | |
| clubs | |
| INNER JOIN | |
| kids_and_clubs |
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
| -- Were Ivan and Maria in the same room of the same hotel at the same time? | |
| SELECT g1, g2, h1, r1 | |
| FROM | |
| ( | |
| SELECT guests.name g1, room r1, hotels.name h1 | |
| FROM visits, guests, hotels | |
| WHERE visits.guest_id = guests.guest_id AND visits.hotel_id = hotels.hotel_id | |
| AND guests.name = 'Ivan' | |
| ) t1, |
OlderNewer