Post History
Pyth, 25 23 bytes @f-1aM.:jT;2u+Gs>2GyQU2 Try it online! First, we generate the Fibonacci numbers: u+Gs>2GyQU2 U2 range(2), the list [0, 1] u Apply the follow...
Answer
#2: Post edited
# [Pyth], 25 bytes@f-1aM.:jT;2hM.u,eNsNyQU2[Try it online!][TIO-lt8wf7zj]- First, we generate the Fibonacci numbers:
hM.u,eNsNyQU2U2 range(2), the list [0, 1].u Apply the following function iteratively,saving all results.,eNsN [end(N), sum(N)], where N is the previous listyQ Twice the input number of repetitionshM Take the first entry of each pair.I think there might be a shorter way to do this part, perhaps by using `u` rather than `.u`?- Next, we check for consecutive digits.
- @f-1aM.:jT;2
- f Filter on the following function
- jT; Take the base ten representation of the number.
- ; accesses T's value in the external scope.
- .: 2 Take all pairs of digits.
- aM Map pairs to their absolute difference.
- -1 Check if 1 is not among the differences.
- @ Index the filter result at the input position.
- [Pyth]: https://github.com/isaacg1/pyth
[TIO-lt8wf7zj]: https://tio.run/##K6gsyfj/3yFN1zDRV88qK8TaKMNXr1Qn1a/YrzIw1Oj/fyMDAA "Pyth – Try It Online"
- # [Pyth], <s>25</s> 23 bytes
- @f-1aM.:jT;2u+Gs>2GyQU2
- [Try it online!][TIO-lt8wtkyl]
- First, we generate the Fibonacci numbers:
- u+Gs>2GyQU2
- U2 range(2), the list [0, 1]
- u Apply the following function iteratively,
- returning the final result.
- +G Add to the end of the current list
- s>2G The sum of the last two elements of the current list
- yQ Repeat for twice the input number of repetitions
- Next, we check for consecutive digits.
- @f-1aM.:jT;2
- f Filter on the following function
- jT; Take the base ten representation of the number.
- ; accesses T's value in the external scope.
- .: 2 Take all pairs of digits.
- aM Map pairs to their absolute difference.
- -1 Check if 1 is not among the differences.
- @ Index the filter result at the input position.
- [Pyth]: https://github.com/isaacg1/pyth
- [TIO-lt8wtkyl]: https://tio.run/##K6gsyfj/3yFN1zDRV88qK8TaqFTbvdjOyL0yMNTo/38jAwA "Pyth – Try It Online"
#1: Initial revision
# [Pyth], 25 bytes @f-1aM.:jT;2hM.u,eNsNyQU2 [Try it online!][TIO-lt8wf7zj] First, we generate the Fibonacci numbers: hM.u,eNsNyQU2 U2 range(2), the list [0, 1] .u Apply the following function iteratively, saving all results. ,eNsN [end(N), sum(N)], where N is the previous list yQ Twice the input number of repetitions hM Take the first entry of each pair. I think there might be a shorter way to do this part, perhaps by using `u` rather than `.u`? Next, we check for consecutive digits. @f-1aM.:jT;2 f Filter on the following function jT; Take the base ten representation of the number. ; accesses T's value in the external scope. .: 2 Take all pairs of digits. aM Map pairs to their absolute difference. -1 Check if 1 is not among the differences. @ Index the filter result at the input position. [Pyth]: https://github.com/isaacg1/pyth [TIO-lt8wf7zj]: https://tio.run/##K6gsyfj/3yFN1zDRV88qK8TaKMNXr1Qn1a/YrzIw1Oj/fyMDAA "Pyth – Try It Online"