Code Self Study Forum

Puzzle: Beginner Series #2 Clock [reference]

Beginner Series #2 Clock” is a coding puzzle that people can be attempted in the following languages: csharp, javascript, ruby, java, python, prolog, cfml, c, typescript, julia, swift, solidity, shell, scala, rust, reason, r, purescript, powershell, php, ocaml, objc, nim, lua, kotlin, haskell, groovy, sql, racket, go, nasm, vb, elixir, elm, erlang, fsharp, fortran, crystal, cpp, clojure, factor, forth, dart, coffeescript, haxe, and cobol.

  • Difficulty: 8 kyu
  • Stars: 156
  • Votes: 2659
  • Category: reference
  • Tags: Fundamentals
  • Source: codewars

Description

Clock shows ‘h’ hours, ‘m’ minutes and ‘s’ seconds after midnight.

Your task is to make ‘Past’ function which returns time converted to milliseconds.

Example:

c
past(0, 1, 1) == 61000

javascript
past(0, 1, 1) == 61000

csharp
Past(0, 1, 1) == 61000

python
past(0, 1, 1) == 61000

ruby
past(0, 1, 1) == 61000

java
Past(0, 1, 1) == 61000

prolog
past(0, 1, 1, 61000).

cfml
past(0, 1, 1) == 61000

typescript
past(0, 1, 1) === 61000

coffeescript
past(0, 1, 1) == 61000

julia
past(0, 1, 1) == 61000

clojure
(= (past 0 1 1) 61000)

cpp
past(0, 1, 1) == 61000

crystal
past(0, 1, 1) == 61000

dart
past(0, 1, 1) == 61000

elixir
past(0, 1, 1) == 61000

elm
past 0 1 1 == 61000

erlang
past(0, 1, 1) =:= 61000

factor
0 1 1 past 61000 =

forth
0 1 1 past 61000 =

fortran
past(0, 1, 1) == 61000

fsharp
past 0 1 1 = 61000

go
past(0, 1, 1) == 61000

groovy
past(0, 1, 1) == 61000

haskell
past 0 1 1 == 61000

kotlin
past(0, 1, 1) == 61000

lua
past(0, 1, 1) == 61000

nasm
past(0, 1, 1) == 61000

nim
past(0, 1, 1) == 61000

objc
past(0, 1, 1) == 61000

ocaml
past 0 1 1 == 61000

php
past(0, 1, 1) == 61000

powershell
Past(0, 1, 1) == 61000

purescript
past 0 1 1 == 61000

r
past(0, 1, 1) == 61000

racket
(= (past 0 1 1) 61000)

reason
past(0, 1, 1) == 61000

rust
past(0, 1, 1) == 61000

scala
past(0, 1, 1) == 61000

shell
run_shell(args: [0, 1, 1]) == 61000

solidity
past(0, 1, 1) == 61000

sql
{h: 0, m: 1, s: 1} => res: 61000

swift
past(0, 1, 1) == 61000

vb
Past(0, 1, 1) == 61000

haxe
past(0, 1, 1) == 61000

cobol
MOVE 0 TO Hours
MOVE 1 TO Minutes
MOVE 1 TO Seconds
PERFORM Past
* Millis = 61000

Input constraints: 0 <= h <= 23, 0 <= m <= 59, 0 <= s <= 59

Solve It Here

Click the link below to solve it on Codewars:

Notes

This puzzle was posted by a Slackbot via a slash command. If you want to help work on the app, send a message to @Josh.

If you don’t want to see the coding puzzles when you visit the forum, you can go into your settings and mute the puzzles category.

I did this one in Elixir.