Write a function named setAlarm which receives two parameters. The first parameter, employed, is true whenever you are employed and the second parameter, vacation is true whenever you are on vacation.
The function should return true if you are employed and not on vacation (because these are the circumstances under which you need to set an alarm). It should return false otherwise.
Example:
setalarm(true, true) -> false
setalarm(false, true) -> false
setalarm(false, false) -> false
setalarm(true, false) -> true
This challenge comes from Swolebrain at CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Latest comments (20)
My solution in js
No prior experience in Python just wanted to give it a try. Like it :) Going to spend more time on the docs in the coming days.
My solution in Python
Solved On Purescript
crackin' out the ol' Clojure 🤔
don'ttest me 😗at least with named non-positional parameters . . .
. . . there's less confusion about how silly this is 😂
Haskell
JS:
In go:
Go Playground example
How about prolog?
A file with one fact should do it...
To run..
Prolog still scares me . . . not its syntax, but seemingly untapped potential.
I'm sorry, but it seems like you've lost the challenge somewhere.
At first I thought I've probably missed something, but then I saw the comments and realized it wasn't me, it was whoever came up with this challenge.
If I may offer a twist - Do it in a language you've never worked with before.
I'll take Scala for a ride on this one:
Nope, sorry, still too easy.
Java
In C#
Public bool setalarm(bool employed = false, bool vacation = false){
return !vacation && employed;
}
nicer with some formatting:
Interresting of you use
vacation
first and your use of default values 😄in Gwion.
Using the newly implemented pattern matching ability.
I should implement implicit casting from bool to int and vice-versa.
EDIT: done and working.
BONUS:
!
operator as boolean, which hopefully makes more senseElixir:
x86-64 assembly (NASM syntax):
Python with optional typing indicators and tests
Some comments may only be visible to logged-in visitors. Sign in to view all comments.