I'd like to know how many problems we have that have solutions of a length of only one line, especially problems that can be solved with an elegant list comprehension. This is so that I can more easily introduce functional programming to others. So far, I found 3 such problems: 1, 16, and 48.
I am not asking for solutions, but only for the listing of problems that are simple enough to do this with.
oneliner solutions
Re: oneliner solutions
This obviously depend on which programming language you are targeting. You won't find too many with C/C++ and its derivatives. You could probably find over 100 with APL/J/K.
When you assume something, you risk being wrong half the time.
Re: oneliner solutions
I'm targeting scripting languages with syntax similar to the English language, particularly Python. Those languages have some of the capabilities of the languages you mentioned.
Re: oneliner solutions
Problems between 70 and 190 that allow oneliners in Maple: (this list is by no means complete)
Problem 71 (View Problem)
Problem 72 (View Problem)
Problem 73 (View Problem)
Problem 97 (View Problem)
Problem 131 (View Problem)
Problem 137 (View Problem)
Problem 138 (View Problem)
Problem 145 (View Problem)
Problem 158 (View Problem)
Problem 162 (View Problem)
Problem 163 (View Problem)
Problem 172 (View Problem)
Problem 173 (View Problem)
Problem 175 (View Problem)
Problem 179 (View Problem)
Problem 183 (View Problem)
Problem 190 (View Problem)
For a few of these problems, you can simply copy the problem statement into maple (like 97), but usually it's not so simple (175 being the hardest imo). Have fun
Problem 71 (View Problem)
Problem 72 (View Problem)
Problem 73 (View Problem)
Problem 97 (View Problem)
Problem 131 (View Problem)
Problem 137 (View Problem)
Problem 138 (View Problem)
Problem 145 (View Problem)
Problem 158 (View Problem)
Problem 162 (View Problem)
Problem 163 (View Problem)
Problem 172 (View Problem)
Problem 173 (View Problem)
Problem 175 (View Problem)
Problem 179 (View Problem)
Problem 183 (View Problem)
Problem 190 (View Problem)
For a few of these problems, you can simply copy the problem statement into maple (like 97), but usually it's not so simple (175 being the hardest imo). Have fun
Re: oneliner solutions
I have done some solutions with python, each in one line. Here the solutions for problem 1, 6, 8, 9, 13, 16, 19, 20, 25 and 29 described.
Edit by hk: spoilers removed.
Edit by hk: spoilers removed.
 Lord_Farin
 Posts: 239
 Joined: Wed Jul 01, 2009 9:43 am
 Location: Netherlands
Re: oneliner solutions
I am afraid that as this is an open forum, there is a policy that no spoilers on how to solve problems are allowed to be posted. So, could you please edit out the links?wingi wrote:I have done some solutions with python, each in one line. Here are the solutions for problem 1, 6, 8, 9, 13, 16, 19, 20, 25 and 29 described.
Edit by hk: spoilers removed.
Re: oneliner solutions
Using Ruby, I have problems 1, 6, 16, 20, 29 and 30 in one line so far.

 Posts: 1
 Joined: Sat Jan 04, 2020 8:35 pm
Re: oneliner solutions
I’ve solved problem 89 in a oneliner, in Python with list comprehension.
This includes reading the input file, processing all lines and discerning the different cases in which a gain can be made as well as counting the total gain.
(Only) for those of you who have also already solved 89: you can view my solution in the thread: https://projecteuler.net/thread=89;page=6#316624
This includes reading the input file, processing all lines and discerning the different cases in which a gain can be made as well as counting the total gain.
(Only) for those of you who have also already solved 89: you can view my solution in the thread: https://projecteuler.net/thread=89;page=6#316624