Skip to content

Instantly share code, notes, and snippets.

View FranklinGuan's full-sized avatar
🎯
Focusing

Franklin Gear FranklinGuan

🎯
Focusing
View GitHub Profile
@FranklinGuan
FranklinGuan / Codewars-5kyu-Calculating_with_Functions.js
Last active April 5, 2020 03:03
Calculating with Functions 5kyu-Codewars
function exp(num,op){
if(!op){return num}
return op(num)
}
function zero(op) { return exp(0,op) }
function one(op) {return exp(1,op)}
function two(op) {return exp(2,op)}
function three(op) {return exp(3,op)}
function four(op) {return exp(4,op)}
@FranklinGuan
FranklinGuan / Codewars-4kyu-Human_readable_duration_format.js
Last active April 3, 2024 12:30
Human readable duration format 4kyu-Codewars
//Introduction
// Your task in order to complete this Kata is to write a function which formats a duration, given as a number of seconds, in a human-friendly way.
// The function must accept a non-negative integer. If it is zero, it just returns "now". Otherwise, the duration is expressed as a combination of years, days, hours, minutes and seconds.
// It is much easier to understand with an example:
// formatDuration(62) // returns "1 minute and 2 seconds"
// formatDuration(3662) // returns "1 hour, 1 minute and 2 seconds"
// For the purpose of this Kata, a year is 365 days and a day is 24 hours.
// Note that spaces are important.
@FranklinGuan
FranklinGuan / Codewars-6kyu-Your order, please.js
Last active July 1, 2023 12:37
Your order, please.js 6kyu-Codewars
//link https://www.codewars.com/kata/your-order-please
//Introduction
// Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result.
// Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0).
// If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers.
//Examples
// "is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est"
// "4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople"
// "" --> ""