Login Register


Code Golf Challenge #1 - Thue-Morse Sequence filter_list
Author
Message
RE: Code Golf Challenge #1 - Thue-Morse Sequence #21
(08-19-2015, 02:21 PM)Shebang Wrote: n=1 still prints [0,1]. It should just print [0].

Fixed, again. If this isn't it, I'm hanging the ethernet cord. You can ask @"Panty" what the means if you want to know.

Examples (0,1,6,20):

Code:
LVL 79 (1716/3853) ~ ●●● node ~/bin2.js [] LVL 79 (1803/3853) ~ ●●● node ~/bin2.js [ 0 ] LVL 79 (1891/3853) ~ ●●● node ~/bin2.js [ 0, 1, 1, 0, 1, 0 ] LVL 79 (1981/3853) ~ ●●● node ~/bin2.js [ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1 ]

100 bytes exactly, with 1 digit values.
[Image: BXqGARG.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #22
(08-19-2015, 02:38 PM)eclipse Wrote: Yeah he just needs to set it to print the first n elements of what's returned.

(08-19-2015, 02:49 PM)Stocking Wrote: Fixed, again. If this isn't it, I'm hanging the ethernet cord. You can ask @"Panty" what the means if you want to know.

Examples (0,1,6,20):

Code:
LVL 79 (1716/3853) ~ ●●● node ~/bin2.js [] LVL 79 (1803/3853) ~ ●●● node ~/bin2.js [ 0 ] LVL 79 (1891/3853) ~ ●●● node ~/bin2.js [ 0, 1, 1, 0, 1, 0 ] LVL 79 (1981/3853) ~ ●●● node ~/bin2.js [ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1 ]

100 bytes exactly, with 1 digit values.

Looks like it's working! Nicely done Smile

Both of you feel free to update your answers to shorten them if you'd like Smile A quick note, you may define an anonymous lambda function to do the work for you, which seems similar to what Stocking did. In that case, only the body of the function is your byte count! (I think that makes your solution around 91 bytes or so, Stocking).

I'll reveal my reference solution in a few languages once the challenge is over.
[Image: CDUAq9d.png]

[+] 1 user Likes Shebang's post
Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #23
(08-19-2015, 02:56 PM)Shebang Wrote: Looks like it's working! Nicely done Smile

Both of you feel free to update your answers to shorten them if you'd like Smile

I'll reveal my reference solution in a few languages once the challenge is over.

I'm going to work on @Eclipse's solution. Since I know that making it even smaller would bother him. Tongue
[Image: BXqGARG.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #24
(08-19-2015, 02:58 PM)Stocking Wrote: I'm going to work on @Eclipse's solution. Since I know that making it even smaller would bother him. Tongue

If you can get anywhere close to my reference Python solution I will be impressed Tongue
[Image: CDUAq9d.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #25
(08-19-2015, 02:58 PM)Stocking Wrote: I'm going to work on @Eclipse's solution. Since I know that making it even smaller would bother him. Tongue

Screw you.

Spoiler:
Tell me how you manage.

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #26
(08-14-2015, 08:52 PM)eclipse Wrote: http://repl.it/BBso
119 bytes

Example outputs:
Code:
T0 --> 0 T1 --> 01 T2 --> 0110 T3 --> 01101001 T4 --> 0110100110010110 T5 --> 01101001100101101001011001101001 T6 --> 0110100110010110100101100110100110010110011010010110100110010110 T7 --> 01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011001011001101001100101101001011001101001

EDIT: I may try golfing this further.

(08-19-2015, 03:00 PM)Shebang Wrote: If you can get anywhere close to my reference Python solution I will be impressed Tongue

(08-19-2015, 03:18 PM)eclipse Wrote: Screw you.

Spoiler:
Tell me how you manage.

Did it in 79 bytes (77 if you take away the first set of parenthesis). Tongue

Code:
>>> r = lambda i: [(0 if int(bin(x)[2:].count('1'))%2==0 else 1) for x in range(i)] >>> r(0) [] >>> r(1) [0] >>> r(6) [0, 1, 1, 0, 1, 0] >>> r(20) [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1]
[Image: BXqGARG.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #27
(08-19-2015, 03:51 PM)Stocking Wrote: Did it in 79 bytes (77 if you take away the first set of parenthesis). Tongue

Code:
>>> r = lambda i: [(0 if int(bin(x)[2:].count('1'))%2==0 else 1) for x in range(i)] >>> r(0) [] >>> r(1) [0] >>> r(6) [0, 1, 1, 0, 1, 0] >>> r(20) [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1]

Nicely done Smile Remove some spaces in a few places and change the logic slightly, and you'll be close to the reference solution length Smile You can also remove the function definition (i.e. r=) and just let it be an anonymous lambda function.
[Image: CDUAq9d.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #28
There's only a little over 24 hours left to go! Get your entries in! Smile
[Image: CDUAq9d.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #29
(08-20-2015, 04:44 PM)Shebang Wrote: There's only a little over 24 hours left to go! Get your entries in! Smile

Adding all my NSP to the pot (25).
[Image: BXqGARG.png]

Reply

RE: Code Golf Challenge #1 - Thue-Morse Sequence #30
(08-20-2015, 04:47 PM)Stocking Wrote: Adding all my NSP to the pot (25).

Awesome, thanks!

(08-20-2015, 04:47 PM)Stocking Wrote: Adding all my NSP to the pot (25).

I would also like to point out that if you want, you can golf your current Py2 solution down to the optimal fairly easily Smile
(This post was last modified: 08-20-2015, 05:12 PM by Shebang.)
[Image: CDUAq9d.png]

Reply







Users browsing this thread: 1 Guest(s)