Skip to content

Instantly share code, notes, and snippets.

@eggplants
Last active December 2, 2023 14:14
Show Gist options
  • Save eggplants/71c0459f38028938a15d35b19bab47b5 to your computer and use it in GitHub Desktop.
Save eggplants/71c0459f38028938a15d35b19bab47b5 to your computer and use it in GitHub Desktop.
Shellgei Online Judge 回答 1~38 - https://shellgei-online-judge.com/
problemNum shellgei
00000001 echo test
00000002 echo $(<input.txt)
00000003 seq 10
00000004 awk '{a=0;for(i=1;i<=NF;){a+=$(i++)}print a}' input.txt
00000005 j=1;for i in {0..10};do echo ${f:-0};((k=f+j,f=j,j=k));done
00000006 bc -l<<<'4*a(1)'|cut -b-12
00000007 bc -l<<<'scale=999;4*a(1)'|tr -d '\\\\\n'|cut -b-102
00000008 awk '{print x=$1-(y=$2/2-$1),y}' input.txt
00000009 sed -zr 's/([^\n])\n([^\n])/\1@\2/g' input.txt|sort -rV|while read i;do [ -n "$i" ]&&echo $i$'\n'|tr @ \\n;done|sed \$d
00000010 a=(川 魚 新幹線 富士山);head -1 input.txt;while read i;do sed "s/ /${a[$((n++))]}/" <<<"$i";done< <(sed 1d input.txt)
00000011 rs -Tg1<input.txt|rev
00000012 tr 01 10 <input.txt
00000013 echo {a..z} $(cat input.txt)|grep -oE .|sort|uniq -u
00000014 awk '{a[$2]=a[$2]" "$1}END{for(b in a)print b""a[b]}' input.txt
00000015 ruby -rprime -ne'puts Prime.prime?($_.to_i)?:YES: :NO'<input.txt
00000016 cat input.txt
00000017 ruby -e'puts`dd<input.txt 2>/dev/null`.split.map(&:to_i).sort'
00000018 ruby -e'_=`<input.txt tr N n`.chop.gsub($/,"&&");p (1..100).select{|n|eval _}.first'
00000019 awk '$0=substr($0,0,length/3)' input.txt
00000020 ruby -rprime -e'puts`dd<input.txt 2>/dev/null`.split.map(&:to_i).map{|n|n.prime?? :素数:Prime.prime_division(n).map{[_1.to_s]*_2}.flatten.map(&:to_s)*?\s}'
00000021 ruby -ple'$_=$_==$_.reverse ? :YES: :NO'<input.txt
00000022 ruby -e'p (2**1024).to_s.size'
00000023 ruby -ple'$_=$_.chars.map{{A:1,B:1,C:1,D:2,E:2,F:3}[_1.to_sym]}.sum'<input.txt
00000024
00000025 ruby -e'puts "ABC".chars.permutation.map(&:join)'
00000026
00000027
00000028 ruby -e'puts %W{ccccc cbbbc cbabc cbbbc ccccc}.map{|i|i.chars.map{_1.ord-96}*""}*$/'
00000029 ruby -e'puts %W{uvwxy tghij sfabk redcl qponm}.map{|i|i.chars.map{_1.ord-87}*?\s}*$/'
00000030 tr 'A-Z' 'S-ZA-S'<input.txt
00000031 ruby -e'p`dd<input.txt 2>/dev/null`.split.map(&:to_i).reduce{_1 ? _1.gcd(_2):_2}'
00000032 ruby -e'p`dd<input.txt 2>/dev/null`.split.map(&:to_i).reduce(1){_1.lcm _2}'
00000033 awk -F '' '$0=$1" "length' input.txt
00000034 ruby -ple'$_=eval"(#{$_}**0.2).to_i"' <input.txt
00000035 sed p input.txt
00000036 cat input.txt|while read i;do for _ in `seq $i`;{ echo $i;};done
00000037 grep -oE '[0-9]+' input.txt
00000038 cat input.txt|while read a b;do sed $'/1/cYes\ncNo'<<<$((a%b?0:1));done
@eggplants
Copy link
Author

eggplants commented May 7, 2023

import requests

shellgei, problemNum = "echo test", "00000001"

url = {
    "run": "https://shellgei-online-judge.com/connection.php",
    "problem": f"https://shellgei-online-judge.com/problem/{problemNum}.txt",
    "input": f"https://shellgei-online-judge.com/input/{problemNum}.txt",
    "output": f"https://shellgei-online-judge.com/output/{problemNum}.txt",
}

data = {
    "shellgei": shellgei,
    "problemNum": problemNum,
}

res_problem = requests.get(url=url["problem"]).text.encode("latin-1").decode("utf-8")
res_input = requests.get(url=url["input"]).text.encode("latin-1").decode("utf-8")
res_output = requests.get(url=url["output"]).text.encode("latin-1").decode("utf-8")
res_run = requests.post(url=url["run"], data=data).json()



print(f"""
## Problem

{res_problem}

## Input

{res_input}

## Output

{res_output}

## Result

{res_run}
""",
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment