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
public class RideFareCalculator { | |
// in real system, these values must be configurable outside of code | |
private static final double BASE_FARE = 3.0; | |
private static final double RATE_PER_KM = 2.50; | |
private static final double RATE_PER_MINUTE = 0.50; | |
private static final double MINIMUM_FARE = 5.0; | |
public static double calculateFare(double distanceKm, double timeMinutes, double surgeMultiplier) { | |
if (distanceKm < 0 || timeMinutes < 0 || surgeMultiplier < 0) { |
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
const fs = require("fs"); | |
let data = fs.readFileSync("./quicksearch.json"); | |
data = data.toString().trim().split("\n").map(JSON.parse); | |
const usernames = new Set(); | |
for (let row of data) { | |
if (row.headers) { |
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
@echo off | |
set JAVA_HOME=C:\Users\Dell\.jdks\openjdk-17.0.2 | |
setx JAVA_HOME "%JAVA_HOME%" | |
set Path=%JAVA_HOME%\bin;%Path% | |
echo Java 17 activated as user default. | |
move c:\Users\Dell\.m2\*.xml c:\Users\Dell\.m2\settings | |
echo setting files moved inside successfully |
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
/** | |
* check if N is a power of 2 | |
* e.g, if N=8, then N is 2^3 | |
*/ | |
const isPowerOfTwo = (num) => { | |
// odd number can never be a power of two | |
if (num % 2 !== 0) return false; | |
let quotient = 0; | |
let chunks = []; |
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
/** | |
* @author Ali Ahmad | |
* The program solves the following problem | |
* | |
* Write a c++ function that splits the string X into an array | |
* bases on the delimeter character Y. | |
* string* tokenizer(string X, char Y) | |
* | |
* Test cases: | |
* X: "1,2,3,4" Returns string array of size 4 with the elements |
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
// for random selection of radio buttons | |
const radioContainers = document.querySelectorAll(".js_radio"); | |
radioContainers.forEach((container) => { | |
const radioInputs = container.querySelectorAll("input"); | |
const index = Math.round(Math.random() * 4); | |
radioInputs[index].checked = true; | |
}); |
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
class foo { | |
var $x = 'y'; // or you can use public like... | |
public $x = 'y'; //this is also a class member variables. | |
function bar() { | |
} | |
} |