Design principles and best practices for creating consistent, accessible, and high-quality user experiences across Apple platforms.
Use the sidebar to navigate the core topics.
| FROM ruby:2.7.1-alpine | |
| ENV BUNDLER_VERSION=2.1.4 | |
| RUN apk add --update --no-cache \ | |
| binutils-gold \ | |
| build-base \ | |
| curl \ | |
| file \ | |
| g++ \ |
| # str = "3x + 2 + x/6 = 5", expected: 0.94736 | |
| # str = "3x = 9", expected: 3.0 | |
| # str = '3x - 2 + x/6 = 5', expected: 2.21 | |
| # program to solve linear equation with arg as str format of linear eqn. | |
| def linear_equation(str) | |
| elements = str.split(' ') | |
| nums = [] | |
| xs = [] | |
| signs = ['+', "-"] | |
| next_sign = 1 |
| # Expected arg to be 2-d array and each sub array to have 2 numbers representing range-start and range-end | |
| # [[1, 4], [6, 6], [6, 8], [1, 10]], expected: [[1, 10]] | |
| # program to solve finding the overlapping ranges and combining them. | |
| def range_flatten(arr) | |
| res = []; done = [] | |
| arr.each_with_index do |range, i| | |
| a = range.first; b = range.second | |
| arr[(i+1)..-1].each_with_index do |other_range, j| | |
| next if done.include?(i+j+1) | |
| def factorial(n) | |
| return 1 if n==1 | |
| n*factorial(n-1) | |
| end |
| def custom_flat (arr, res = []) | |
| arr.each_with_index do |ele, i| | |
| if arr[i].class.name == "Array" | |
| #p "ARR - #{arr[i]}" | |
| custom_flat arr[i], res | |
| else | |
| #p "ELE - #{arr[i]}" | |
| res << arr[i] | |
| #p res | |
| end |