Last active
August 29, 2015 14:07
-
-
Save aisk/f04070aa968a28ea0cba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require("assert"); | |
var activities = { | |
"Aqua aerobics": 4, | |
"Athletics, high jump, long jump, triple jump, javelin, pole vault": 6, | |
"Athletics, shot, discus, hammer": 4, | |
"Athletics, steeplechase, hurdles": 10, | |
"Badminton, competitive": 7, | |
"Badminton, social": 4.5, | |
"Baseball": 5, | |
"Basketball, game": 8, | |
"Basketball, shooting baskets": 4.5, | |
"Bowling": 3, | |
"Boxing, punching bag": 6, | |
"Boxing, sparring": 9, | |
"Calisthenics, heavy, vigorous effort": 8, | |
"Calisthenics, light or moderate effort": 3.5, | |
"Canoeing, rowing, light effort": 3, | |
"Canoeing, rowing, moderate effort": 7, | |
"Canoeing, rowing, vigorous effort": 12, | |
"Carpentry, general": 3, | |
"Carpentry, rain gutters, fencing": 6, | |
"Carpentry, sawing hardwood": 7.5, | |
"Carpet laying/removal": 4.5, | |
"Carrying groceries upstairs": 7.5, | |
"Chopping wood": 6, | |
"Circuit training, general": 8, | |
"Cleaning gutters": 5, | |
"Cleaning, house, general": 3, | |
"Conditioning exercise, health club exercise, general": 5.5, | |
"Conditioning exercise, stretching, hatha yoga": 2.5, | |
"Cricket [batting, bowling]": 5, | |
"Cycling, less than 16.1 km/h": 4, | |
"Cycling, 16.1-19.2 km/h": 6, | |
"Cycling, 19.3-22.4 km/h": 8, | |
"Cycling, 22.5-25.6 km/h": 10, | |
"Cycling, 25.7-30.6 km/h, racing not drafting": 12, | |
"Cycling, drafting at more than 30.6 km/h, very fast, racing general": 12, | |
"Cycling, more than 32.2 km/h, racing not drafting": 16, | |
"Cycling, BMX or mountain": 8.5, | |
"Cycling, general": 8, | |
"Cycling, stationary, 50 watts, very light effort": 3, | |
"Cycling, stationary, 100 watts, light effort": 5.5, | |
"Cycling, stationary, 150 watts, moderate effort": 7, | |
"Cycling, stationary, 200 watts, vigorous effort": 10.5, | |
"Cycling, stationary, 250 watts, very vigorous effort": 12.5, | |
"Dancing, aerobic general": 6.5, | |
"Dancing, ballet, modern, jazz, tap, jitterbug": 4.79999999999999, | |
"Dancing, ballroom, slow": 3, | |
"Dancing, Greek, Middle Eastern, hula, flamenco, belly, swing": 4.5, | |
"Diving, springboard or platform": 3, | |
"Elliptical trainer": 7, | |
"Fencing": 6, | |
"Fishing, general": 3, | |
"Football, competitive": 9, | |
"Frisbee, general": 3, | |
"Frisbee, ultimate": 8, | |
"Gardening, digging": 5, | |
"Gardening, general": 4, | |
"Gardening, mowing lawn": 5.5, | |
"Gardening, planting trees": 4.5, | |
"Gardening, raking lawn": 4.29999999999999, | |
"Golf, general": 4.5, | |
"Gymnastics": 4, | |
"Handball, team": 8, | |
"Hockey, field or ice": 8, | |
"Horseback riding, general": 4, | |
"Household cleaning, general": 3, | |
"Household tasks, moderate effort": 3.5, | |
"Hunting, general": 5, | |
"Ice skating": 7, | |
"Ironing": 2.29999999999999, | |
"Judo, jujitsu, karate, kickboxing, tae kwan do": 10, | |
"Kayaking": 5, | |
"Lacrosse": 8, | |
"Lawn bowls": 3, | |
"Motorcross": 4, | |
"Moving furniture, household items, carrying boxes": 6, | |
"Orienteering": 9, | |
"Painting, papering, plastering": 3, | |
"Pilates": 3.5, | |
"Polo": 8, | |
"Rock climbing, ascending": 11, | |
"Rock climbing, rappelling": 8, | |
"Rollerblading": 12.5, | |
"Rollerskating": 7, | |
"Roofing": 6, | |
"Rowing machine, general": 7, | |
"Rugby": 10, | |
"Running, 3 mins 26 secs per km": 18, | |
"Running, 3 mins 44 secs per km": 16, | |
"Running, 4 mins 9 secs per km": 15, | |
"Running, 4 mins 20 secs per km": 14, | |
"Running, 4 mins 40 secs per km": 13.5, | |
"Running, 5 mins per km": 12.5, | |
"Running, 5.5 mins per km": 11, | |
"Running, 6 mins 12 secs per km": 10, | |
"Running, 7 mins 10 secs per km": 9, | |
"Running, 7.5 mins per km": 8, | |
"Running, cross country": 9, | |
"Running, jog/walk combination": 6, | |
"Running, up stairs": 15, | |
"Sailing, competition": 5, | |
"Sailing, general": 3, | |
"Scuba diving": 7, | |
"Sexual activity, light effort": 1, | |
"Sexual activity, moderate effort": 1.3, | |
"Sexual activity, vigorous effort": 1.5, | |
"Skateboarding": 5, | |
"Skiing": 7, | |
"Skipping, with rope": 10, | |
"Sledding, tobogganing": 7, | |
"Snorkelling": 5, | |
"Snow shoeing": 8, | |
"Soccer, casual": 7, | |
"Soccer, competitive": 10, | |
"Softball": 5, | |
"Softball, pitching": 6, | |
"Speed skating competitive": 15, | |
"Squash": 12, | |
"Stair-treadmill ergometer, general": 9, | |
"Step aerobics, high step": 10, | |
"Step aerobics, low step": 8.5, | |
"Stretching": 2.5, | |
"Surfing, body or board": 3, | |
"Sweeping floors, carpets": 3.29999999999999, | |
"Swimming laps, freestyle, moderate or light effort": 7, | |
"Swimming laps, freestyle, vigorous": 10, | |
"Swimming, backstroke": 7, | |
"Swimming, breaststroke": 10, | |
"Swimming, butterfly": 11, | |
"Table tennis [ping pong]": 4, | |
"Tai chi": 4, | |
"Tennis, doubles": 6, | |
"Tennis, general": 7, | |
"Tennis, singles": 8, | |
"Touch football": 8, | |
"Trampoline": 3.5, | |
"Vacuuming": 3.5, | |
"Volleyball, 6-9 member team": 3, | |
"Volleyball, beach": 8, | |
"Volleyball, indoor competitive": 8, | |
"Walk/run, playing with animals - moderate": 4, | |
"Walk/run, playing with children - moderate": 4, | |
"Walking the dog": 3, | |
"Walking, 3.2 kph": 2.5, | |
"Walking, 4.02 kph": 3, | |
"Walking, 4.82 kph": 3.29999999999999, | |
"Walking, 5.6 kph": 3.79999999999999, | |
"Walking, 6.4 kph": 5, | |
"Walking, 7.24 kph": 6.29999999999999, | |
"Walking, 8 kph": 8, | |
"Watching TV, sitting quietly": 1, | |
"Water aerobics": 4, | |
"Water jogging": 8, | |
"Water polo": 10, | |
"Waterskiiing": 6, | |
"Weight lifting, light or moderate effort": 3, | |
"Weight lifting, vigorous effort": 6, | |
"Wiring, plumbing": 3, | |
"Wrestling match": 6, | |
"Yoga, hatha": 2.5 | |
}; | |
var sexual = "male"; | |
var height = 176; | |
var weight = 120; | |
var age = 26; | |
var activity = "Yoga, hatha"; | |
var mets = activities[activity]; | |
var time = 30; // minutes | |
var calulate = function () { | |
assert(age >= 18 && age <= 123); | |
if (sexual === "male") { | |
var v = 66.5 + (13.75 * weight) + (5.003 * height) - (6.775 * age); | |
} else { | |
var v = 655.1 + (9.563 * weight) + (1.85 * height) - (4.676 * age); | |
} | |
v = (v * mets) / 24; | |
var kph = v; // amount per hour | |
var total = v * time / 60; | |
console.log("kph: " + kph + "; total: "+ total + ";"); | |
} | |
calulate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var translations = { | |
"Aqua aerobics": 4, | |
"Athletics, high jump, long jump, triple jump, javelin, pole vault": 6, | |
"Athletics, shot, discus, hammer": 4, | |
"Athletics, steeplechase, hurdles": 10, | |
"Badminton, competitive": 7, | |
"Badminton, social": 4.5, | |
"Baseball": 5, | |
"Basketball, game": 8, | |
"Basketball, shooting baskets": 4.5, | |
"Bowling": 3, | |
"Boxing, punching bag": 6, | |
"Boxing, sparring": 9, | |
"Calisthenics, heavy, vigorous effort": 8, | |
"Calisthenics, light or moderate effort": 3.5, | |
"Canoeing, rowing, light effort": 3, | |
"Canoeing, rowing, moderate effort": 7, | |
"Canoeing, rowing, vigorous effort": 12, | |
"Carpentry, general": 3, | |
"Carpentry, rain gutters, fencing": 6, | |
"Carpentry, sawing hardwood": 7.5, | |
"Carpet laying/removal": 4.5, | |
"Carrying groceries upstairs": 7.5, | |
"Chopping wood": 6, | |
"Circuit training, general": 8, | |
"Cleaning gutters": 5, | |
"Cleaning, house, general": 3, | |
"Conditioning exercise, health club exercise, general": 5.5, | |
"Conditioning exercise, stretching, hatha yoga": 2.5, | |
"Cricket [batting, bowling]": 5, | |
"Cycling, less than 16.1 km/h": 4, | |
"Cycling, 16.1-19.2 km/h": 6, | |
"Cycling, 19.3-22.4 km/h": 8, | |
"Cycling, 22.5-25.6 km/h": 10, | |
"Cycling, 25.7-30.6 km/h, racing not drafting": 12, | |
"Cycling, drafting at more than 30.6 km/h, very fast, racing general": 12, | |
"Cycling, more than 32.2 km/h, racing not drafting": 16, | |
"Cycling, BMX or mountain": 8.5, | |
"Cycling, general": 8, | |
"Cycling, stationary, 50 watts, very light effort": 3, | |
"Cycling, stationary, 100 watts, light effort": 5.5, | |
"Cycling, stationary, 150 watts, moderate effort": 7, | |
"Cycling, stationary, 200 watts, vigorous effort": 10.5, | |
"Cycling, stationary, 250 watts, very vigorous effort": 12.5, | |
"Dancing, aerobic general": 6.5, | |
"Dancing, ballet, modern, jazz, tap, jitterbug": 4.79999999999999, | |
"Dancing, ballroom, slow": 3, | |
"Dancing, Greek, Middle Eastern, hula, flamenco, belly, swing": 4.5, | |
"Diving, springboard or platform": 3, | |
"Elliptical trainer": 7, | |
"Fencing": 6, | |
"Fishing, general": 3, | |
"Football, competitive": 9, | |
"Frisbee, general": 3, | |
"Frisbee, ultimate": 8, | |
"Gardening, digging": 5, | |
"Gardening, general": 4, | |
"Gardening, mowing lawn": 5.5, | |
"Gardening, planting trees": 4.5, | |
"Gardening, raking lawn": 4.29999999999999, | |
"Golf, general": 4.5, | |
"Gymnastics": 4, | |
"Handball, team": 8, | |
"Hockey, field or ice": 8, | |
"Horseback riding, general": 4, | |
"Household cleaning, general": 3, | |
"Household tasks, moderate effort": 3.5, | |
"Hunting, general": 5, | |
"Ice skating": 7, | |
"Ironing": 2.29999999999999, | |
"Judo, jujitsu, karate, kickboxing, tae kwan do": 10, | |
"Kayaking": 5, | |
"Lacrosse": 8, | |
"Lawn bowls": 3, | |
"Motorcross": 4, | |
"Moving furniture, household items, carrying boxes": 6, | |
"Orienteering": 9, | |
"Painting, papering, plastering": 3, | |
"Pilates": 3.5, | |
"Polo": 8, | |
"Rock climbing, ascending": 11, | |
"Rock climbing, rappelling": 8, | |
"Rollerblading": 12.5, | |
"Rollerskating": 7, | |
"Roofing": 6, | |
"Rowing machine, general": 7, | |
"Rugby": 10, | |
"Running, 3 mins 26 secs per km": 18, | |
"Running, 3 mins 44 secs per km": 16, | |
"Running, 4 mins 9 secs per km": 15, | |
"Running, 4 mins 20 secs per km": 14, | |
"Running, 4 mins 40 secs per km": 13.5, | |
"Running, 5 mins per km": 12.5, | |
"Running, 5.5 mins per km": 11, | |
"Running, 6 mins 12 secs per km": 10, | |
"Running, 7 mins 10 secs per km": 9, | |
"Running, 7.5 mins per km": 8, | |
"Running, cross country": 9, | |
"Running, jog/walk combination": 6, | |
"Running, up stairs": 15, | |
"Sailing, competition": 5, | |
"Sailing, general": 3, | |
"Scuba diving": 7, | |
"Sexual activity, light effort": 1, | |
"Sexual activity, moderate effort": 1.3, | |
"Sexual activity, vigorous effort": 1.5, | |
"Skateboarding": 5, | |
"Skiing": 7, | |
"Skipping, with rope": 10, | |
"Sledding, tobogganing": 7, | |
"Snorkelling": 5, | |
"Snow shoeing": 8, | |
"Soccer, casual": 7, | |
"Soccer, competitive": 10, | |
"Softball": 5, | |
"Softball, pitching": 6, | |
"Speed skating competitive": 15, | |
"Squash": 12, | |
"Stair-treadmill ergometer, general": 9, | |
"Step aerobics, high step": 10, | |
"Step aerobics, low step": 8.5, | |
"Stretching": 2.5, | |
"Surfing, body or board": 3, | |
"Sweeping floors, carpets": 3.29999999999999, | |
"Swimming laps, freestyle, moderate or light effort": 7, | |
"Swimming laps, freestyle, vigorous": 10, | |
"Swimming, backstroke": 7, | |
"Swimming, breaststroke": 10, | |
"Swimming, butterfly": 11, | |
"Table tennis [ping pong]": 4, | |
"Tai chi": 4, | |
"Tennis, doubles": 6, | |
"Tennis, general": 7, | |
"Tennis, singles": 8, | |
"Touch football": 8, | |
"Trampoline": 3.5, | |
"Vacuuming": 3.5, | |
"Volleyball, 6-9 member team": 3, | |
"Volleyball, beach": 8, | |
"Volleyball, indoor competitive": 8, | |
"Walk/run, playing with animals - moderate": 4, | |
"Walk/run, playing with children - moderate": 4, | |
"Walking the dog": "遛狗", | |
"Walking, 3.2 kph": 2.5, | |
"Walking, 4.02 kph": 3, | |
"Walking, 4.82 kph": 3.29999999999999, | |
"Walking, 5.6 kph": 3.79999999999999, | |
"Walking, 6.4 kph": 5, | |
"Walking, 7.24 kph": 6.29999999999999, | |
"Walking, 8 kph": 8, | |
"Watching TV, sitting quietly": 1, | |
"Water aerobics": 4, | |
"Water jogging": 8, | |
"Water polo": 10, | |
"Waterskiiing": 6, | |
"Weight lifting, light or moderate effort": 3, | |
"Weight lifting, vigorous effort": 6, | |
"Wiring, plumbing": 3, | |
"Wrestling match": 6, | |
"Yoga, hatha": 2.5 | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment