benchmarks.wiki / Public workspace
..·::-==++*********++==-::·.. ..·:--==+++++==--::··........·::-=+**#%@@@@%#*+=-:·
..···::-----===------:::··... ..···::::::::::···........··::--==++@@@@@@%#*+=-:·.
......············....... ..........................·····:**@@@@@@%#*+=-:·.
·:++@@@@@@%#*+=-:·.
··==######*++=-:·..
..--+++====--::··.
..··:::::::····...
...............
......·····::::::::····..... ...............
...............····:::--==+++++++++==--:::···..........·····:::::::·····..................
......················:::--=++*##%%%@%%%##**+==---::::::::----=======----:::··········:::·····...
..·:--=+**##%%%%%#**+=-:·. ..·::---===--::··.. ..··:--=++**######*+=-:··.
...···:::---======--::··.. ...········.... ...··::---====%%%%%%#*+=-:·.
.........·······..... .....······++%%@@@@%#*+=-:·.
··==%%%%%%%#*+=-:·.
··--****##**++=-:·.
..::-====++===--:·.
..···::-----::··.
...········..
....··..
.........··················....... ................................ .....
....··:::::::-----===========---::::····........······:::::-----:::::··················...
..···::------====+++****######***++==---:::::::::::---====+++++++====----------=====----::·..
.·:-=+*##%@@@@@%%#*+=-:·. ..··::------::··.. ..···::::----------::··..
..··::--===++++==--:··.. ........... ...·····::::::=======--:··.
.....·········.... ............:-+++++++==-:··.
..--++*****+==-:·.
..::+++**#**+=--:.
..·:===+****++=-:·.
.·:--=++*+++=-:·.
..·::-==++==-:·.
..·:---==--:·.
...···::::::·······..... .........·············..................... ..·::---::·.
..··:-==++++++++++===--::···..... ........····::::---------------::::-----------:::··... .··::::··.
..·::-=+###%%%%@@%%%%##*++=--:···........····:::--===++++++++++++++++++++*****##***++=--:·.. ..·····..
..·::-=+*##%%%%%%##**+==-::··..........··::---=====--::·.. .....·····...
...··::--========---::··.... .....········.... ....······...
....··········..... ..··········...
.·:::::::::··..
..··-----=--::··..
..··-===++==--:··.
..·:==+++*++=--:·.
.··-=++*#**+=-:·.
.·--=+*##**+=-:·.
...···::····.... .........··································..... ..:-=++*#**+=-:·.
..·:-==+***++==--:··... ....····::::-------------------====++++++===--::··... .·:-=+****+=-:·.
.·:-+*#%@@@@@@%##*+=-:··.. ....···::---================+++**##%%%%%%%%#**+=-::·.. ..·:-=+++++=-:·.
..··::--==+++*********+++++=====----------===++********++=--:··. .··::---::·.
...···::::-----------::::::·············:::::------:::···.. .··:::::··.
.........···............. ................. ..···::···.
..·······..
....·······..
...···········..
··::::::::····..
..··-------:::··..
..::==++++=--::·..
.......... ......................·······:::::::::::·····.................:-+*****++=-:··.
.··::-----::··... ......·····:::::::::::::::::---===++++++++++==--:::···.......···:::--**#####*+=-:·.
.·:-=+**##**+=-::·... ....····::::::::::::::::::--==++*##%%%%%%%##*++=--::···.....··::--=++*##%%%%#*=-:·.
..·::-=+++++++==========+++++++++++++++***##%%%@@@@@@@@%##*+==-::····........ .·:-=++***+=-:·.
...·::-------::::::::::::::::::::::::-----=====+++====--:::··................ ··:=++*++=-:·.
....·····..............................··········...... ...... ..·:-+++==-:·.
.··:=====-:·.
.·:------:·.
..·::---::·.
..··:::::··.
....···::···..
..············..
......... ........·····::::::::::·······..................··-:::::::···..
....................................·····............···::---==++++++++===---::::::::::::-----------====---::··..
..····:::·····...............················..........··::-=++**#######**++==--::::::---==++***######***+++=-:··..
.·::--=====----======+++++++++++****##%%@@@@@@@@@@@@@@%##*+++====-------:::··.. .··:-==++**##*+==-:·.
..··:::--:::::······::::::::::::----====++++++++++===--::::···············.... ..··:++**##**+=-:·.
.....··............................············......... .............. ··=+**###*+=-:·.
.·-=+**#**+=-:·.
..:-=+****+=-:·.
.::-=+**++=-:·.
.·::-=+++=--:·.
.·::-===--::·.
.··::----::·..
................. ....·····:::::::··········............. ..····:::::··..
...····:::::::················....... ...··::--===========-----:::::::--------::::·····..····:::···...
...·::::--------------:::::::::···.... ..·::-==++*******+++==--------===+++*******+++==---::::::···...
.··::--=======================+++**##%@@@@@@@@@@@%%###**************+++==--::···.........····:::---===+++**#*++=-:·.
...···::::::::::::::::::::::::----====++++++===----::::::::::::::::::::···.... ....···:::::+++****+==-:·.
...............................·········....... .............. .....:-++*****+=-::·.
..:-+*****++=-:··.
..:-+*****++=-:·..
..:-+*****++=-:·..
..::++****+=--:·.
..::=+++**+=-:··.
.·:==++++=--:·..
....······................. ....················.......... .··--====--:··.
..··:-----------:::::::::::····.... ..··::---=========----::::::::··········..........····------::·...
..·:-==++++++++++++++++++===--::··... ..··:-==++**###***+++==------------=====------::::::::::::::::··..
.··:-==+*+++===---:::::::::--==++***########************####%%%%####***+++===------:::::::···::::--==+**#%%@%#*+=-:·
..··::-----:::::········:::::------------:::::······:::::--------:::::···························::::+**####*+=-:·.
....................................... .............. ................::+++****+=-:··.
..::++++++==-:··.
..--+++++==-:··..
··--++++==-::·..
··--*+++==-:·..
··=-**++==-:·..
··=-**++=-:··.
.....······................ ....·············..... ......····--*++==-:·..
..··::------=========-----:::··.... ....··::--==++++++===---::···.... ...··:::-------++==-:··.
.·::-=+***#####%%%%%%###**+==-::··......··::-=++*##%%%%%%%##**+==--::····............···::--===++++++===-::·.
.·:---===--::·····..·····::---==================++**##%%%%@@@@@%%%%####***+++==---::·······:::-==+**#%%%@@@@%#+=-:·.
..··:::--::::··········:::::::--::::::············:::-------------------::::::::::·············:::--==##%%%%#*+=::·.
.....···........................... .................................................--******+=-::·.
..--+++++==-:·..
..::====--:··.
..::=---::·..
··-:=--:··.
··--=--:·..
··--==-:·..
....················..... ....·············.... ...····::::::···=-+=-:··.
...··:--=====++++++===--:::··........···::-==+++*****++==--::·.. ..··:--==++++++++==-+=-:··.
.··:-=+*##%%%@@@@@@%%#**+=--::·····:::-=+*##%@@@@@@@@@@%%#*+=-:··. .··:-=+*#%%@@@@%%#**+=-:·..
..···::::···.....····::::---------::::----==++**##%%@@@@@@@@@%%%###**++===--:::······:::--=++***#########***+=-:··.
...····:::·······:::::::---::::::··········::::---=============--------:::::············::::---=======##***+=-:··..
.....·....···············...... ..................................................·······==***++=-:··..
··--++==-:··..
·.-:=--:··.
..::-:··.
..:·:··.
·.:·:·..
·.:·:·..
....·············.... .....·····::······... ...···::::::::::::····::-:·.
..··:-===+++++===--::···........··::--=+++*******++=--:·.. .·:--=+***********++=--:-:··.
..·:-=*##%%%%%%%##*+==-::·······:--=+*#%@@@@@@@@@@@@%#*+=-·. .·:=+*#%@@@@@@@@@@@%#*+=-::·...
.....·······::::------------::::----==+**#%%@@@@@@@@@@@%%#**++=--:::········:::--==+++***********++==---::··.....
...···::::::-------------:::::::::::---===++++***+++++===---:::·····.......····:::---============---==-:::··....
....········::::·······.............···················........... ........················--=--::··...
··-:--:··..
·.::::·..
..····.
..·.·.
..·...
..·...
...·········.... .....···········.... ...····:::::::::::::····..···...
..·::-=====--::··... ...··:--==+++***+++==-:··. .··:-==+*************++=--:··:···.........
.··:-+*##***++=-::·... ...··:-=+**#%@@@@@@@@@@%#+=-:·. .·:-=+#%@@@@@@@@@@@@@@%#*+=--:::········...
...··:----==========---------==+**#%@@@@@@@@@@@@@%#*+=-::·... ...··:--==++****####****++==--:··... ....
...··:----========-----::::----==+++*************++=--:··... ...··:::--===++++++++===---::··.··............
...···:::::::::·······....······::::::::::::::::····... ....·····::::::::::·····..··:···.........
..:·:···........
..····......
..·.·...
......
. .... .......
. .........···...
.....·..... .....·······...... .....····:::::::::::····.... ..·····::::···..
..··::::::··.. ...··::---=====---::··... ..···:--==+++********+++==-:::····::::-----::··.
..·::-====-:··. ..··:-==+**#######**+=-::·. .··:-=++*#%@@@@@@@@@@@%%#*++==--------===---:··.
..··:--========-----::----=++*#%@@@@@@@@@@@@@%#*+-:··. ..··:--==+++**********++==-::··.. ..······.
..··:---===-----:::::::---==++***************+=--:·.. ..··::--===+++++++++===--::···......···::::::··.
...··············.....·····:::::::::::::::::::··... ...····:::::::::::::····.....··:::::----::··.
..··-:------:::·..
..··::::---:::··..
..··:::::::::··..
..·.··::::::···..
..··:::::::··..
..::::----::··..
..... .......................... .....······:·······....... ··::--===--::·..
...···... ...····::::::::::::::········............···::---===++++===---:::·········--===+==--:··.
.···:::··.. ...··::---======-----::::::··············:::--==++**###%%%###**+==---:::::----===++==--:··.
..··::---:::·········::-=++*#%@@@@@@@@@@%#*+=-:·.. ...··::--==+++*******++==-::·... ..··:-=====--:·.
..···::::···········::--==+*************+==-:·.. ...··::---===+++++===---::····....··--=+*****+=-:·.
....................···:::::::::::::::::··... ....····::::::::::·····........::++**#%##*+=-:·
..--***##%#*+=-:·.
..--+******+=-:··.
..::=+++++==-::·..
..::-=====--::·..
..··-------::··..
··:------::··..
.....······:::::·····.... ......·······....... ··-------::··..
..... ....····:::---=========--::···...........···:::------::::····........·····-------::··..
..···... .....·····:::---==+++*****+++==--::::··::::---===++++++===--:::········:::::-------::···..
..... ..·::-=+**##%%%%%##**+==-:··.. ..··:--=++******++=--::··.......·::-=+*#%@%#*+=-:·.
.. ..··::--==++******++==--:··... ...··::---======---:::··········::--#%@@@@%#*+=-:·.
....···:::::::::::::···... .....··············..........···=+@@@@@@%#*+=-:·.
··++@@@@@@%#*+=-·.
··==%%%%%%#*+=-:·.
··--****++==-:··..
..::====---:···..
..··::::::···...
..·······....
.....····::::::::::···.... ............... ..·····......
....··::--==++*****+++=--::··............····::::::·····.....................··.........
......... ......··::-==+*##%%@@@%%%#**+==-:::::·:::::-----==----:::·····....··············...........
██████╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗ ███████╗███╗ ██╗ ██████╗██╗ ██╗
██╔══██╗██║██╔════╝ ██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗██╔════╝████╗ ██║██╔════╝██║ ██║
██████╔╝██║██║ ███╗██║ ██║ ██║██║ ██║█████╗ ██████╔╝█████╗ ██╔██╗ ██║██║ ███████║
██╔══██╗██║██║ ██║██║ ██║ ██║██║ ██║██╔══╝ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██╔══██║
██████╔╝██║╚██████╔╝╚██████╗╚██████╔╝██████╔╝███████╗██████╔╝███████╗██║ ╚████║╚██████╗██║ ██║
╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝$ open /benchmarks/bigcodebench/tasks/default--v0~2e1~2…▌ posts · files
BigCodeBench / BigCodeBench v0.1.0_hf 010aebf5-3bc5-58ec-8400-667dd389afaa
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
import itertools
def task_func(data_list):
"""
Unzips a list of tuples and calculates the mean of the numeric values for
each position.
The function accepts a list of tuples, where each tuple consists of
alphanumeric values. It unzips the tuples, and calculates the mean of
numeric values at each position using numpy, where non numeric values are
ignores. If all values at a position are non numeric, the mean at this
position is set to be np.nan.
If the provided tuples have different number of entries, missing values are
treated as zeros.
Parameters:
- data_list (list of tuples): The data to process, structured as a list of tuples. Each tuple can contain alphanumeric values.
Returns:
- list: A list of mean values for each numeric position across the tuples. Non-numeric positions are ignored.
An empty list is returned if the input list (data_list) is empty.
Requirements:
- numpy
- itertools
Example:
>>> task_func([('a', 1, 2), ('b', 2, 3), ('c', 3, 4), ('d', 4, 5), ('e', 5, 6)])
[nan, 3.0, 4.0]
>>> task_func([(1, 'a', 2), ('a', 3, 5), ('c', 1, -2)])
[1.0, 2.0, 1.6666666666666667]
"""
instruct prompt
Unzips a list of tuples and calculates the mean of the numeric values for each position. The function accepts a list of tuples, where each tuple consists of alphanumeric values. It unzips the tuples, and calculates the mean of numeric values at each position using numpy, where non numeric values are ignores. If all values at a position are non numeric, the mean at this position is set to be np.nan. If the provided tuples have different number of entries, missing values are treated as zeros.
The function should output with:
list: A list of mean values for each numeric position across the tuples. Non-numeric positions are ignored.
An empty list is returned if the input list (data_list) is empty.
You should write self-contained code starting with:
Code
import numpy as np
import itertools
def task_func(data_list):
code prompt
Code
import numpy as np
import itertools
def task_func(data_list):
entry point
task_func
libs
- numpy
- itertools
Discussion
No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
Source and history
- task_id
010aebf5-3bc5-58ec-8400-667dd389afaa- task_key
default--v0~2e1~2e0~5fhf--010aebf5-3bc5-58ec-8400-667dd389afaa- task_revision_id
- 1
- config / split
- default / v0.1.0_hf
initial import