Skip to content

Instantly share code, notes, and snippets.

@ashraf267
ashraf267 / work.js
Created July 2, 2022 10:37
work in progress solution.
let input = require('sync-input');
console.log("Welcome to Currency Converter!");
console.log(`1 USD equals 1 USD
1 USD equals 113.5 JPY
1 USD equals 0.89 EUR
1 USD equals 74.36 RUB
1 USD equals 0.75 GBP`);
console.log("What do you want to convert?");
let fromCurrency = "USD";
let toCurrency = "EUR";
let amount = 89;
let result = "";
if(fromCurrency == "USD") {
// for USD
let usdRates = {
usd: 1,
jpy: 113.5,
@ashraf267
ashraf267 / newSolution.js
Created July 4, 2022 12:56
Second version of the Currency Converter that worked.
let input = require('sync-input');
console.log("Welcome to Currency Converter!");
console.log(`1 USD equals 1 USD
1 USD equals 113.5 JPY
1 USD equals 0.89 EUR
1 USD equals 74.36 RUB
1 USD equals 0.75 GBP`);
console.log("What do you want to convert?");
@ashraf267
ashraf267 / doings.js
Created July 7, 2022 22:41
Another style for the currency converter (v2)
let currencies = [
{
name: "JPY",
val: 113.5,
},
{
name: "EUR",
val: 0.89,
},
{
@ashraf267
ashraf267 / magic.js
Created July 11, 2022 23:06
Thank God!
let input = require('sync-input');
console.log("Welcome to Currency Converter!");
console.log(`1 USD equals 1 USD
1 USD equals 113.5 JPY
1 USD equals 0.89 EUR
1 USD equals 74.36 RUB
1 USD equals 0.75 GBP`);
(function myCurrConv() {
@ashraf267
ashraf267 / 9-fizz_buzz.c
Created September 17, 2022 00:45
Modern problems, modern solutions :)
#include <stdio.h>
int main() {
void print(int n);
int i;
for (i = 1; i <= 100; i++) {
if (i % 15 == 0) {
putchar('F');
@ashraf267
ashraf267 / ing-word-check.dart
Created January 23, 2023 23:26
This dart code checks if a given word ends with 'ing' (return true) or not (return false)
void main() {
// todo
print("Hello World!");
HighEngine firstWord = HighEngine(word: 'engine');
print(firstWord.word);
print(firstWord.checkWord());
// sandbox
@ashraf267
ashraf267 / fcfsv1.dart
Created March 1, 2023 04:08
first-come-first-serve scheduling algorithm v1
void main() {
// tasks
// task a
// prints even nos between 1 - 100000
// exec. time: to be calculated
// arrival time: roughly 5s
// task b
// prints even nos between 1 - 1000000
@ashraf267
ashraf267 / fcfsv2.dart
Created March 1, 2023 04:56
first-come-first-serve. This works!
void main() {
// function call
fcfs([
// then this, secondly
Task(
't1', 10,
),
// by rule, this should exec. first
Task(
't2', 0,
@ashraf267
ashraf267 / fcfsv3.dart
Created March 2, 2023 11:43
This is working but results are not correct - needs tweaking!
void main() {
// function call
fcfs([
// then this, secondly
Task(
't1', 10, 20,
),
// by rule, this should exec. first
Task(
't2', 0, 25,