Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Golfed by two bytes; added alternate methods.
Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127

TI-BASIC, 24(削除) 24 (削除ここまで) 22

-1+int(11fPart(11^Ans.0954191038120954191904

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this minusless one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

Also 24 bytes is base-10 encoding using edc65's trick of subtracting one only whenin the input iscase of 6. The leads to this 24-byte solution, where 10^( is a single one-byte token displayed as "10^:

-(Ans≠6)+int(10fPart(.106003909710^(Ans

The string approach is 29 bytes:

-(Ans≠6)+expr(inString("1060039097",Ans+1,1

The array approach (".which Ypnpyn also took) is 30 bytes, assuming the number is stored in X:

{1,0,6,0,0,3,10,0,9,7}-1:Ans(X+1

-(Ans≠6)+int(10fPart(.106003909710^(X 24 -> 22: Removed two extra digits of precision in the magic constant.

TI-BASIC, 24

-1+int(11fPart(11^Ans.095419103812

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this minus one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

Also 24 bytes is base-10 encoding using edc65's trick of subtracting one only when the input is 6. The 10^( is a single token displayed as "10^(".

-(Ans≠6)+int(10fPart(.106003909710^(X

TI-BASIC, (削除) 24 (削除ここまで) 22

-1+int(11fPart(11^Ans.0954191904

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this less one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

edc65's trick of subtracting one in the case of 6 leads to this 24-byte solution, where 10^( is a single one-byte token:

-(Ans≠6)+int(10fPart(.106003909710^(Ans

The string approach is 29 bytes:

-(Ans≠6)+expr(inString("1060039097",Ans+1,1

The array approach (which Ypnpyn also took) is 30 bytes, assuming the number is stored in X:

{1,0,6,0,0,3,10,0,9,7}-1:Ans(X+1

24 -> 22: Removed two extra digits of precision in the magic constant.

Added second 24-byte method.
Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127

TI-BASIC, 24

-1+int(11fPart(11^Ans.095419103812

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this minus one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

I have not been able to exploit any order inAlso 24 bytes is base-10 encoding using edc65's trick of subtracting one only when the datainput is 6. The 10^( is a single token displayed as "10^(".

-(Ans≠6)+int(10fPart(.106003909710^(X

TI-BASIC, 24

-1+int(11fPart(11^Ans.095419103812

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this minus one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

I have not been able to exploit any order in the data.

TI-BASIC, 24

-1+int(11fPart(11^Ans.095419103812

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this minus one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

Also 24 bytes is base-10 encoding using edc65's trick of subtracting one only when the input is 6. The 10^( is a single token displayed as "10^(".

-(Ans≠6)+int(10fPart(.106003909710^(X

Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127

TI-BASIC, 24

-1+int(11fPart(11^Ans.095419103812

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this minus one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.

I have not been able to exploit any order in the data.

AltStyle によって変換されたページ (->オリジナル) /