Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#GNU dc, 14 bytes

Borrowing @Dennis's clever base 9 trick@Dennis's clever base 9 trick:

9i[?A%nd]dxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline d # duplicate macro d # duplicate macro xxxx # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 

#GNU dc, 14 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?A%nd]dxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline d # duplicate macro d # duplicate macro xxxx # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 

#GNU dc, 14 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?A%nd]dxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline d # duplicate macro d # duplicate macro xxxx # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 
added 23 characters in body
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268

#GNU dc, 1514 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?A%n]dddxxxxA%nd]dxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline d ddd  #  duplicate macro   3 times (4 copies)  d # duplicate macro  xxxx  # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 

#GNU dc, 15 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?A%n]dddxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline ddd # duplicate macro 3 times (4 copies)  xxxx # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 

#GNU dc, 14 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?A%nd]dxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline d   #  duplicate macro   d # duplicate macro  xxxx  # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 
added 60 characters in body
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268

#GNU dc, 1615 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?%An]dxdxdxdxA%n]dddxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline ddd # duplicate macro 3 times (4 copies) xxxx # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 1918 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dxdxdxdxA%n]dddxxxx 

#GNU dc, 16 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?%An]dxdxdxdx 

Input integers read from STDIN, one per line.

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 19 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dxdxdxdx 

#GNU dc, 15 bytes

Borrowing @Dennis's clever base 9 trick:

9i[?A%n]dddxxxx 

Input integers read from STDIN, one per line.

###Explanation:

9i # Set input radix to 9 [ ] # push a macro, defined thus: ? # read number from STDIN and push A # push literal 10 % # calculate number mod 10 n # print, with no newline ddd # duplicate macro 3 times (4 copies) xxxx # execute the macro 4 times 

###Output:

$ for i in 57 23 99 45; do echo $i; done | dc ./combolock.dc 2101$ $ for i in 25 78 63 15; do echo $i; done | dc ./combolock.dc 3174$ $ 

###Previous Answer, 18 bytes:

Because I thought I could get closer to the "golfing" languages with this (but didn't):

[A?A~--A%n]dddxxxx 
added 60 characters in body
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268
Loading
deleted 1 character in body
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268
Loading
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268
Loading