Skip to main content
Golfed from 16 to 13 using David Hammond's method.
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127

TI-BASIC, 20 17 16 15-1613

BecauseBecause it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command. Maybe it is tokenized, TI-BASIC is often competitive at simple math challengesafter all, but not this one since there is no "divisible" commandstill longer than CJam and Pyth. 16 bytes:

This uses David Hammond's method.

not(fPart(Ans/16not4/4^not(fPart(sub(Ansnot(fPart(Ans/4

UngolfedOld code at 16 bytes:

not(fPart(Ans/16) and not16not(fPart(Ans/100) and notsub(Ansnot(fPart(Ans/4))))
//equivalent to:

Ungolfed:

not(fPart(Ans/16)) orand not(fPart(Ans/100) and not(fPart(Ans/4))))

fPart( is "fractional part", and there is implied multiplication going onpart"; exponentiation has higher precedence than division. In TI-BASIC allows elision of, close-parens, so to minimize the size, seven have been removed. If output of 0 for a leap year and a positive float for a non-leap year is acceptable, the first not( can be removed, making the code 15 bytes are optional.

This usesI use undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This codeIt will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could have been divisible(16,Ansdivisible(E2,Ansdivisible(4,Ans.

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

parens; 17  ->16> 16 by replacing 400 with 16; 16 -> 13 by using David Hammond's idea.

TI-BASIC, 20 17 15-16

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command. 16 bytes:

not(fPart(Ans/16not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/16) and not(fPart(Ans/100) and not(fPart(Ans/4))))
//equivalent to:
not(fPart(Ans/16)) or (fPart(Ans/100) and not(fPart(Ans/4)))

fPart( is "fractional part", and there is implied multiplication going on. TI-BASIC allows elision of close-parens, so to minimize the size, seven have been removed. If output of 0 for a leap year and a positive float for a non-leap year is acceptable, the first not( can be removed, making the code 15 bytes.

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could have been divisible(16,Ansdivisible(E2,Ansdivisible(4,Ans.

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

17->16 by replacing 400 with 16.

TI-BASIC, 20 17 16 13

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command. Maybe it is after all, but this is still longer than CJam and Pyth.

This uses David Hammond's method.

not(fPart(Ans/4/4^not(fPart(sub(Ans

Old code at 16 bytes:

not(fPart(Ans/16not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/16) and not(fPart(Ans/100) and not(fPart(Ans/4))))

fPart( is "fractional part"; exponentiation has higher precedence than division. In TI-BASIC, close-parens are optional.

I use undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. It will work on a TI-83 or 84 series calculator.

20 -> 17 by rearranging code to allow removal of close-parens; 17  -> 16 by replacing 400 with 16; 16 -> 13 by using David Hammond's idea.

Golfed by one to two bytes to 16-15.
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127

TI-BASIC, 20 17 1715-16

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command. 16 bytes:

not(fPart(Ans/400not16not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/40016) and not(fPart(Ans/100) and not(fPart(Ans/4))))
//equivalent to:
not(fPart(Ans/16)) or (fPart(Ans/100) and not(fPart(Ans/4)))

fPart( is "fractional part", and there is implied multiplication going on. TI-BASIC allows elision of close-parens, so to minimize the size, seven have been removed. If output of 0 for a leap year and a positive float for a non-leap year is acceptable, the first not( can be removed, making the code 15 bytes.

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could behave been divisible(40016,Ansdivisible(E2,Ansdivisible(4,Ans, but there is not.

Also seventeen bytes is:

fPart(.5sum(not(fPart(Ans/{4,E2,400

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

17->16 by replacing 400 with 16.

TI-BASIC, 20 17

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command.

not(fPart(Ans/400not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/400) and not(fPart(Ans/100) and not(fPart(Ans/4))))

fPart( is "fractional part", and there is implied multiplication going on. TI-BASIC allows elision of close-parens, so to minimize the size, seven have been removed.

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could be divisible(400,Ansdivisible(E2,Ansdivisible(4,Ans, but there is not.

Also seventeen bytes is:

fPart(.5sum(not(fPart(Ans/{4,E2,400

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

TI-BASIC, 20 17 15-16

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command. 16 bytes:

not(fPart(Ans/16not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/16) and not(fPart(Ans/100) and not(fPart(Ans/4))))
//equivalent to:
not(fPart(Ans/16)) or (fPart(Ans/100) and not(fPart(Ans/4)))

fPart( is "fractional part", and there is implied multiplication going on. TI-BASIC allows elision of close-parens, so to minimize the size, seven have been removed. If output of 0 for a leap year and a positive float for a non-leap year is acceptable, the first not( can be removed, making the code 15 bytes.

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could have been divisible(16,Ansdivisible(E2,Ansdivisible(4,Ans.

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

17->16 by replacing 400 with 16.

added 257 characters in body
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127

TI-BASIC, 20 17

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command.

not(fPart(Ans/400not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/400) and not(fPart(Ans/100) and not(fPart(Ans/4))))

fPart( is "fractional part", and there is implied multiplication going on. TI-BASIC allows elision of close-parens, so to minimize the size, seven have been removed.

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could be divisible(400,Ansdivisible(E2,Ansdivisible(4,Ans, but there is not.

Also seventeen bytes is:

fPart(.5sum(not(fPart(Ans/{4,E2,400

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

TI-BASIC, 20 17

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command.

not(fPart(Ans/400not(fPart(sub(Ansnot(fPart(Ans/4

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could be divisible(400,Ansdivisible(E2,Ansdivisible(4,Ans, but there is not.

Also seventeen bytes is:

fPart(.5sum(not(fPart(Ans/{4,E2,400

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

TI-BASIC, 20 17

Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command.

not(fPart(Ans/400not(fPart(sub(Ansnot(fPart(Ans/4

Ungolfed:

not(fPart(Ans/400) and not(fPart(Ans/100) and not(fPart(Ans/4))))

fPart( is "fractional part", and there is implied multiplication going on. TI-BASIC allows elision of close-parens, so to minimize the size, seven have been removed.

This uses undocumented behavior of the sub( command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. This code will work on a TI-83 or 84 series calculator.

If there were a divisible( command to return 0 or 1 depending on whether the first argument divides the second, the code could be divisible(400,Ansdivisible(E2,Ansdivisible(4,Ans, but there is not.

Also seventeen bytes is:

fPart(.5sum(not(fPart(Ans/{4,E2,400

Edit: 20 -> 17 by rearranging code to allow removal of close-parens.

Added second line of same size
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127
Loading
added 203 characters in body
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127
Loading
Golfed by 3 bytes.
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127
Loading
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127
Loading