๐Ÿ”จ๐Ÿช†๐Ÿž๐Ÿชž๐ŸŒ๏ธ

Code Golf 0X001

Toronto ยท Oct 28, 2023

~ Taha

(Thanks Effective Altruism Canada for the room)

๐Ÿ“Œ Plan for today:

๐Ÿ”Œ First, setup your machine and get ready!

๐Ÿงช Then we solve 3 problems (starting ~ 2:30pm)

๐Ÿ”ง Problem #1: A warm up, and getting in the zone (Until 3:30pm)

โ›ฝ๏ธ Present your code and discuss solutions together (Until 4:00pm)

๐Ÿ”ง Problem #2: More algorithmic and open ended one (Until 4:45pm)

โ›ต๏ธ Problem #3: Most likely no problem 3 for today, to make this first event more chill.

๐Ÿž Having Fun > killing the fun:

  • There will be one and only one winner!
  • Shortest code wins.
  • Some forms of cheating are sometimes fun (Subject to interpretation, decide for yourself).
  • Looking up the answer on the forums kills the fun.
  • Pasting your program in chatgpt to translate to Esolangs is not fun.
  • But, Esolangs are allowed – if you know one.
  • Playing 3D chess by tricking other competitors into losing might be fun. But avoid this if possible.
  • Taking ideas from others and using them in your own program is very fun.

Criteria

  • You can’t store your program in a file. It should run in terminal like this: $ python -c “import this; something something;”

  • If you need to, you can only import standard libraries of your language.

Problem #1

Swap contents of two files:

[ i.txt, o.txt]

  • Rules:

  • You can create a third file if it helps, but your program needs to delete it after swapping is done.

  • Renaming files is allowed.

Problem #2

Flatten an arbitrarily deep nested list.

For example:

[10,20,[30,[40,"hi"],"oh"],50]

should output

[10, 20, 30, 40, 'hi', 'oh', 50]

The list must be read from a file named:

l.txt

Test Cases:

[10,20,30] -> [10,20,30]
[[10]] -> [10]
[["Hi"],[[10]]] -> ["Hi",10]
[[[20],["Hi"],"Hi",20]] -> [20,"Hi","Hi",20]
[[["[]"],"[]"]] -> ["[]","[]"]

Download test cases pasted on https://tahaashtiani.com/codegolf

Happy Hacking!

Stay tuned for next event 0X002, hopefully at this room:

Image