Skip to content

Instantly share code, notes, and snippets.

View Nasah-Kuma's full-sized avatar

Mantoh Nasah Kuma Nasah-Kuma

View GitHub Profile
function getTotalX(a, b) {
// Write your code here
let lowerBoundInt = a[a.length - 1];
let upperBoundInt = b[0];
let arrayInt = [];
let arrayForFactorsOfA = [];
let arrayWhoseFactorsAreB = [];
let finalArr = [];
if(lowerBoundInt > upperBoundInt) {
function countApplesAndOranges(s, t, a, b, apples, oranges) {
// Write your code here
let applesOnHouse = 0;
let orangesOnHouse = 0;
const applesDistancesFromTree = apples.map((apple) => apple+a);
const orangesDistancesFromTree = oranges.map((orange) => orange+b);
applesDistancesFromTree.forEach((appleDistance) => {
if(appleDistance >= s && appleDistance <= t) applesOnHouse++;
})
orangesDistancesFromTree.forEach((orangeDistance) => {
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
@Nasah-Kuma
Nasah-Kuma / atoken.sol
Last active November 12, 2023 14:45
A smart contract that allows the deposit of a token created, and users can only withdraw it after 70 blocks from when it was deposited.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyToken {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract HealthRecordRepository {
enum AdmissionStatus { Admitted, NotAdmitted }
struct HealthRecord {
uint256 recordID;
string patientName;
uint256 age;
@Nasah-Kuma
Nasah-Kuma / heathRecordRepo.sol
Created October 31, 2023 14:20
In this contract, the HealthRecord struct represents a patient's health record, and it includes various data points such as recordID, patientName, age, diagnosis, treatment, medications, and isAdmitted. The addHealthRecord function allows adding a new health record to the repository, while the getPatientRecords and getRecordByID functions enable…
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract HealthRecordRepository {
struct HealthRecord {
uint256 recordID;
string patientName;
uint256 age;
string diagnosis;
string treatment;
/*
* Complete the 'miniMaxSum' function below.
*
* The function accepts INTEGER_ARRAY arr as parameter.
*/
function miniMaxSum(arr) {
// Write your code here
arr.sort();
/*
* Complete the 'sockMerchant' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER n
* 2. INTEGER_ARRAY ar
*/
function sockMerchant(n, ar) {
function plusMinus(arr) {
// Write your code here
let plusCount = 0;
let minusCount = 0;
let zeroCount = 0;
const n = arr.length;
for (const i of arr) {
if(i < 0) minusCount++;
if(i > 0) plusCount++;
/*
* Complete the 'minimumNumber' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER n
* 2. STRING password
*/
function minimumNumber(n, password) {