Skip to content

Instantly share code, notes, and snippets.

View axayjha's full-sized avatar
🚀
work hard, play hard

Akshay Anand axayjha

🚀
work hard, play hard
View GitHub Profile
function getTopStocks(stocks, prices) {
// Step 1: Calculate average for each stock
const n = stocks.length;
const averages = [];
for (let i = 0; i < n; i++) {
let sum = 0;
for (let j = 0; j < prices.length; j++) {
sum += prices[j][i];
}
function parseRobotFile(robotLines) {
const rulesByAgent = { DoeBot: [], "*": [] };
let currentRelevantAgentKey = null;
const UA_PREFIX = "User-agent:";
const DIS_PREFIX = "Disallow:";
for (const rawLine of robotLines) {
const line = rawLine.trim();
import java.util.ArrayList;
import java.util.List;
// The Gson imports shown in the screenshot (com.google.gson.*) are not needed for this problem's core logic.
public class Player { // Assuming CoderPad uses a class named Player or similar
/**
* Calculates the sequence of actions to transform an atom from a starting state
* (protonsStart, neutronsStart) to a target state (protonsTarget, neutronsTarget).
*
import java.util.*;
class Solution {
/**
* @param clusterSize The cluster size of a disk (in bytes).
* @param fileSize The size of a file (in bytes).
* @return The "size on disk" of this file, on this disk (in bytes).
*/
public static int computeSizeOnDisk(int clusterSize, int fileSize) {
// Calculate the number of clusters needed.
/**
* @param {string[]} robotLines The lines of the robots.txt file (only ASCII characters, no newline
* characters at the end was already removed).
* @return {string[]} All the disallowed url patterns that apply to your search engine.
*/
function parseRobotFile(robotLines) {
let doeBotRules = [];
let wildcardRules = [];
// This variable tracks the agent type for the current section being processed.
/**
* Given a list of daily stock prices, return the three stocks with the highest average price.
*
* @param {string[]} stocks - An array of strings, representing the stock names.
* @param {number[][]} prices - An array of arrays, where prices[i] is an array of daily prices for stocks[i].
* @returns {string[]} An array containing the names of up to three stocks with the highest average price,
* sorted by decreasing average value.
*/
function getTopStocks(stocks, prices) {
// Step 1: Calculate the average price for each stock and store it.
@axayjha
axayjha / Material.module.ts
Created November 9, 2021 08:11
Material.module.ts
import { NgModule } from '@angular/core';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatButtonModule} from '@angular/material/button';
import {MatInputModule} from '@angular/material/input';
import {MatAutocompleteModule} from '@angular/material/autocomplete';
import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatRadioModule} from '@angular/material/radio';
import {MatSelectModule} from '@angular/material/select';
import {MatSliderModule} from '@angular/material/slider';
#include <Servo.h>
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 2
int threshold;
int ac=3;
int curtain=5;
Servo myservo;
#define DHTTYPE DHT11
// initialize the library with the numbers of the interface pins
module mul_test_bench;
reg [15:0] data_in;
reg clk, start;
wire done;
datapath DP (eqz, LdA, LdB, LdP, clrP, decB, data_in, clk);
controller CON (LdA, LdB, LdP, clrP, decB, done, clk, eqz, start);
initial
begin
module controller (LdA, LdB, LdP, clrP, decB, done, clk, eqz, start);
input clk, eqz, start;
output reg LdA, LdB, LdP, clrP, decB, done;
reg [2:0] state;
parameter s0=3'b000, s1=3'b001, s2=3'b010, s3=3'b011, s4=3'b100;
always @(posedge clk)
begin
case (state)
s0: if (start) state <= s1;