Skip to content

Instantly share code, notes, and snippets.

View Tr-reny's full-sized avatar
🎯
meditating

Reny kipkoech Tr-reny

🎯
meditating
View GitHub Profile
@Tr-reny
Tr-reny / Problem #2.py
Last active February 12, 2023 10:14
The code calculates the maximum distance between a field and a water tower on a wheat farm for determining the appropriate pump power. The fields and towers are modeled as sorted lists of integers representing their positions. The code uses two pointers to iterate through both lists, finding the maximum difference between a field and tower posit…
# Calculates maximum distance between a field and water tower
def max_power(fields, towers):
fields.sort()
towers.sort()
i, j = 0, 0
max_distance = 0
while i < len(fields) and j < len(towers):
# find the maximum distance between a field and a tower
@Tr-reny
Tr-reny / Problem #1.py
Last active February 12, 2023 10:15
The program finds the maximum number of "A"s that can be printed on the screen given a set of keyboard commands and a number of times the keyboard can be pressed.
# THis code Finds the max 'A' count with given keyboard presses.
def max_a(n):
# initialize dp array with size n + 1
dp = [0] * (n + 1)
# loop through the dp array
for i in range(1, n + 1):
# assign the maximum number of 'A' for dp[i]
@Tr-reny
Tr-reny / Problem #0.py
Last active February 12, 2023 09:32
This is a Intern Developer Assistant Python interview question to of implementation of a binary search algorithm to find the first number of teaspoons of sugar that makes a cake too sweet
# This code implements a binary search algorithm to find the first number of teaspoons of sugar that makes a cake too sweet
def binary_search(n, isTooSweet):
# Set left as lower bound, right as upper bound
left = 1
right = n
# repeat until right - left <= 1
while right - left > 1:
# find average of left and right
@Tr-reny
Tr-reny / Problem test #0.py
Last active February 12, 2023 10:14
This is a Intern Developer Assistant Python interview question to of implementation of a binary search algorithm to find the first number of teaspoons of sugar that makes a cake too sweet.the binary_search t will then takes two inputs, n (the number of teaspoons of sugar required by the recipe) and isTooSweet (a function that returns True if the…
# This code implements a binary search algorithm to find the first number of teaspoons of sugar that makes a cake too sweet
def binary_search(n, isTooSweet):
# Set left as lower bound, right as upper bound
left = 1
right = n
# repeat until right - left <= 1
while right - left > 1:
# find average of left and right
mid = (left + right) // 2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"isbn": "123-456-222",
"author":
{
"lastname": "Doe",
"firstname": "Jane"
},
"editor":
{
"lastname": "Smith",
"firstname": "Jane"
{
"total": 143,
"movies": [
{
"id": "771206971",
"title": "Madagascar 3: Europe's Most Wanted",
"year": 2012,
"mpaa_rating": "PG",
"runtime": 93,
"critics_consensus": "Dazzlingly colorful and frenetic, Madagascar 3 is silly enough for young kids, but boasts enough surprising smarts to engage parents along the way.",
[
{
"Title": "Avatar",
"Year": "2009",
"Rated": "PG-13",
"Released": "18 Dec 2009",
"Runtime": "162 min",
"Genre": "Action, Adventure, Fantasy",
"Director": "James Cameron",
"Writer": "James Cameron",
@Tr-reny
Tr-reny / Employee.json
Created July 26, 2022 14:32
employee json
{
"Employees" : [
{
"userId":"rirani",
"jobTitleName":"Developer",
"firstName":"Romin",
"lastName":"Irani",
"preferredFullName":"Romin Irani",
"employeeCode":"E1",
"region":"CA",