# Pulse Measurement of Heart Arrhythmia

In this challenge you have to make an ascii pulsing heart with rhythm problems (Heart arrhythmia) and then measure the pulse.Don't worry it's easy!

Making the heart

The heart alternates between these 2 states:
state 1

    ,d88b.d88b,
88888888888
Y8888888Y'
Y888Y'
Y'


state 2

     d8b d8b
888888888
Y88888P'
Y888P'
Y8P'
Y'


each step has X seconds delay
where X is a Random (Real) number between 0.3 and 1.4 (0.3<=X<=1.4)

Measuring the Pulse

When your arrhythmia-heart starts beating, you have to measure the pulse.
We want to know the heartbeats/min.
But (like many doctors do) you only have to count the heartbeats for 15 sec and then multiply by 4

Final output

Given no input, your code must run for 15 seconds (displaying the beating heart) and then print the heart rate.

Your output should look exactly like this!
(I will run my code 2 times for you to see the different results)

First example run:

Second example run:

you must output one heart
Good Luck!

this is code-golf

• Could you replace the two hearts with just 1? It makes the post more confusing – caird coinheringaahing Jul 16 '17 at 23:35
• Should the output rate be computed from the pause times or from the actual running time (which will be slightly greater than the sum of pause times)? – Luis Mendo Jul 16 '17 at 23:50
• @cairdcoinheringaahing I've separated the figures to make it clear they are two independent runs – Luis Mendo Jul 16 '17 at 23:52
• @LuisMendo Sorry I was afk.15 sec is the actual running time.Thanks for editing. I wanted to make sure that there is not a unique result. – user72269 Jul 17 '17 at 0:47

# Mathematica, 212 bytes

g=",d88b.d88b,
88888888888
Y8888888Y'
Y888Y'
Y'";h=" d8b d8b
888888888
Y88888P'
Y888P'
Y8P'
Y'";t=1;TimeConstrained[Monitor[While[1<2,If[OddQ@t,b=g,b=h];Pause@RandomReal@{.3,1.4};t++],b],15];4t


# Python [on Windows], 262 bytes

from time import*
import os,random
t,i=time(),0
while time()-t<15:print([""",d88b.d88b,
88888888888
Y8888888Y'
Y888Y'
Y'""",""" d8b d8b
888888888
Y88888P'
Y888P'
Y8P'
Y'"""][i%2]);i+=1;sleep(random.randint(3,14)/10);os.system('cls')
print(i*4)


For linux and macOS use os.system('clear') for 2 more bytes.

• You can xor i to save 2 bytes [i%2];i+=1 becomes [i];i^=1 – caird coinheringaahing Jul 17 '17 at 0:28
• you have extra spaces after your second heart, i got it down to 262 bytes by removing them – Felipe Nardi Batista Jul 17 '17 at 11:04
• @cairdcoinheringaahing I need i for print(i*4) – Uriel Jul 17 '17 at 11:09
• @micsthepick its missing some spaces, it results in one byte more actually – Uriel Jul 17 '17 at 11:10
• @FelipeNardiBatista thanks! fixed – Uriel Jul 17 '17 at 11:10

# Java, 374 bytes

class G{public static void main(String[]a)throws Exception{long t=System.currentTimeMillis(),i=0;while(System.currentTimeMillis()<15000+t){p(",d88b.d88b,\n88888888888\nY8888888Y'\n  Y888Y'\n    Y'\n");Thread.sleep((long)(300+(Math.random()*1100)));i++;p(" d8b d8b\n888888888\nY88888P'\n Y888P'\n  Y8P'\n   Y'\n");}p(i*4);}static<T>void p(T s){System.out.println(s);}}


Ungolfed:

public class Golf {
public static void main(String[]a)throws Exception {
long t=System.currentTimeMillis(),i=0;
while(System.currentTimeMillis()<15000+t) {
p(",d88b.d88b,\n88888888888\nY8888888Y'\n  Y888Y'\n    Y'\n");
p(" d8b d8b\n888888888\nY88888P'\n Y888P'\n  Y8P'\n   Y'\n");
`