![]() |
|
Code Golf Challenge #1 - Thue-Morse Sequence - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: Code Golf Challenge #1 - Thue-Morse Sequence (/Thread-Code-Golf-Challenge-1-Thue-Morse-Sequence) |
RE: Code Golf Challenge #1 - Thue-Morse Sequence - Equinox - 08-19-2015 (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. RE: Code Golf Challenge #1 - Thue-Morse Sequence - Shebang - 08-19-2015 (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. Looks like it's working! Nicely done ![]() Both of you feel free to update your answers to shorten them if you'd like 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. RE: Code Golf Challenge #1 - Thue-Morse Sequence - Equinox - 08-19-2015 (08-19-2015, 02:56 PM)Shebang Wrote: Looks like it's working! Nicely done I'm going to work on @Eclipse's solution. Since I know that making it even smaller would bother him.
RE: Code Golf Challenge #1 - Thue-Morse Sequence - Shebang - 08-19-2015 (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. If you can get anywhere close to my reference Python solution I will be impressed
RE: Code Golf Challenge #1 - Thue-Morse Sequence - Eclipse - 08-19-2015 (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. Screw you. Spoiler:Tell me how you manage. RE: Code Golf Challenge #1 - Thue-Morse Sequence - Equinox - 08-19-2015 (08-14-2015, 08:52 PM)eclipse Wrote: http://repl.it/BBso (08-19-2015, 03:00 PM)Shebang Wrote: If you can get anywhere close to my reference Python solution I will be impressed (08-19-2015, 03:18 PM)eclipse Wrote: Screw you. Did it in 79 bytes (77 if you take away the first set of parenthesis). ![]() 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]RE: Code Golf Challenge #1 - Thue-Morse Sequence - Shebang - 08-19-2015 (08-19-2015, 03:51 PM)Stocking Wrote: Did it in 79 bytes (77 if you take away the first set of parenthesis). Nicely done Remove some spaces in a few places and change the logic slightly, and you'll be close to the reference solution length You can also remove the function definition (i.e. r=) and just let it be an anonymous lambda function.
RE: Code Golf Challenge #1 - Thue-Morse Sequence - Shebang - 08-20-2015 There's only a little over 24 hours left to go! Get your entries in!
RE: Code Golf Challenge #1 - Thue-Morse Sequence - Equinox - 08-20-2015 (08-20-2015, 04:44 PM)Shebang Wrote: There's only a little over 24 hours left to go! Get your entries in! Adding all my NSP to the pot (25). RE: Code Golf Challenge #1 - Thue-Morse Sequence - Shebang - 08-20-2015 (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
|