Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 339 characters in body
Source Link
SomoKRoceS
  • 1.5k
  • 10
  • 17

05AB1E, 62(削除) 62 (削除ここまで) 51 bytes

(-11 from @kevin)

'&¡'=δ¡D€нÙÐV_UsvYyнk©Xsèyθ',««Xs®ǝU}Xε¦ ̈}Yζí'=ý'&ý

Try it online!


My 62 approach:

05AB1E, 62 bytes

05AB1E, (削除) 62 (削除ここまで) 51 bytes

(-11 from @kevin)

'&¡'=δ¡D€нÙÐV_UsvYyнk©Xsèyθ',««Xs®ǝU}Xε¦ ̈}Yζí'=ý'&ý

Try it online!


My 62 approach:

added 2509 characters in body
Source Link
SomoKRoceS
  • 1.5k
  • 10
  • 17

Explanation:

'&¡ε'=¡}D€нÙ©DgÅ0Usvy¬®skDVXsèyθ',««XsYǝU}Xε¦ ̈}®ζεć'=s«« ̃} ̃'&ý
'&¡ split by &
 ε'=¡} foreach: split by =
 D duplicate
 €н foreach: push header (get the keys list)
 Ù uniquify
 © save in register c
 Dg suplicate and get the length of that list of keys
 Å0 create a list of 0's with the length above
 U save in variable X
 svy } for each set of key-value
 ¨sk find the index of that key in the keys list
 DV save the index in variable y
 Xsè get the current value of the element of X at index Y (in X we are keeping the concatenation of the values for key i)
 yθ extract the tail of the element in this iteration (a value to concatenate)
 ',«« concatenate with , in between
 XsYǝU update X with the new value of the element representing the key
 Xε¦ ̈} remove tail and head from each element of X (removing the trailing , and leading 0)
 ® push back the list of keys
 ζ zip (list of keys and list of merged values)
 εć'=s«« ̃} foreach element in the zipped list, join with = in between such that the result is "key=values"
 ̃ flat
 '&ý join with &

Try it online!

Explanation:

'&¡ε'=¡}D€нÙ©DgÅ0Usvy¬®skDVXsèyθ',««XsYǝU}Xε¦ ̈}®ζεć'=s«« ̃} ̃'&ý
'&¡ split by &
 ε'=¡} foreach: split by =
 D duplicate
 €н foreach: push header (get the keys list)
 Ù uniquify
 © save in register c
 Dg suplicate and get the length of that list of keys
 Å0 create a list of 0's with the length above
 U save in variable X
 svy } for each set of key-value
 ¨sk find the index of that key in the keys list
 DV save the index in variable y
 Xsè get the current value of the element of X at index Y (in X we are keeping the concatenation of the values for key i)
 yθ extract the tail of the element in this iteration (a value to concatenate)
 ',«« concatenate with , in between
 XsYǝU update X with the new value of the element representing the key
 Xε¦ ̈} remove tail and head from each element of X (removing the trailing , and leading 0)
 ® push back the list of keys
 ζ zip (list of keys and list of merged values)
 εć'=s«« ̃} foreach element in the zipped list, join with = in between such that the result is "key=values"
 ̃ flat
 '&ý join with &

Try it online!

Source Link
SomoKRoceS
  • 1.5k
  • 10
  • 17

05AB1E, 62 bytes

'&¡ε'=¡}D€нÙ©DgÅ0Usvy¬®skDVXsèyθ',««XsYǝU}Xε¦ ̈}®ζεć'=s«« ̃} ̃'&ý

Try it online!

AltStyle によって変換されたページ (->オリジナル) /