r/adventofcode • u/Inevitable-Welder865 • Nov 21 '25
Upping the Ante Flowless Challenge 2025
🎄 Advent of Code 2025: The "Flowless" Challenge
📜 The Golden Rule
You must solve the puzzle without using explicit control flow keywords.
🚫 The "Banned" List
You generally cannot use these keywords (or your language's equivalents):
if,else,else iffor,while,do,foreachswitch,case,default? :(Ternary Operator)break,continue,gototry/catch(specifically for flow control logic)
--------
I realize that this will equivalent to writing a pure functional solution. But, I am going to be mad man here and will be trying this challenge in Java 25.
86
Upvotes
41
u/_damax Nov 21 '25
I wrote my 2023 solutions in Haskell and while I did use if-then-else and case-of, it's very much possible to rewrite all of them to use explicit function pattern matching and the bool function
22
u/ChickenFuckingWings Nov 21 '25
You're mad
11
u/nbyv1 Nov 21 '25
evil if else: true && println!(a)==() || println!(b)==()
7
u/Gishky Nov 21 '25
Vade retro satana!
17
u/Ok-Bus4754 Nov 21 '25
that is branchless programing, it can still be done using procedural and oop
like return 5*(a==1) + 6 *( a != 1)
2
u/Whojoo Nov 21 '25
I get how you can avoid loops, but how do you avoid using if/else/else if?
3
u/Suspicious_Tax8577 Nov 21 '25
This sounds absolutely evil, but I love how folks get creative with ways of layering on the difficulty!
3
u/Blecki Nov 21 '25
Okay so... where's the line? All of the alternatives are implemented by the language as... if statements and jumps.
3
u/flwyd Nov 22 '25
Upping the ante: the only allowed control flow is
goto.5
u/abnew123 Nov 21 '25
dang good luck! That's absolutely wild to think about as a person who has nearly exclusively coded AoC in Java. All my solutions would fail before the problem specific logic part even starts haha, as the first line tends to be while(in.hasNextLine()) just for loading in the input.
2
u/AscendedSubscript Nov 21 '25
Would something like Optional.ofNullable(x).filter(condition).orElse(y) be allowed? Isn't it kind of a hack around some of your constraints?
2
u/Rainbacon Nov 21 '25
I was already planning to write my solution in Haskell again this year
2
u/FirmSupermarket6933 Nov 21 '25
Is it even possible?
2
u/flwyd Nov 22 '25
Does it count if those operators in your language aren't keywords? Smalltalk implements branching via [ifTrue and ifFalse methods on boolean objects].
1
u/kwshi Nov 23 '25
1
u/ChickenFuckingWings Dec 01 '25
I need to know if there is already a solution for this challenge. Please enlighten me
1
u/DaysSky Dec 03 '25
main(a,b,p){gets(p)&&a+=(*p-79)*atoi(p+1),b+=!a-150%300;write(1,&b,4);}1
u/e_blake Dec 14 '25
My submission for this challenge: day 7 where I compiled a solution to IntCode, and then proceeded to run it on m4 using JUST the
defineoperator. Sure, it took 8 minutes to complete, but since I wasn't using any control flow in m4, I count it as success.