Discuss Scratch

shidaken
Scratcher
38 posts

Scratchスクリプトクイズ

ie_523 wrote:

変数の使用はOKですか?
ie_523
Scratcher
100+ posts

Scratchスクリプトクイズ

attoma-ku wrote:

追記:もしかして、同じ距離ずつ移動するのを複数回繰り返さないとだめですか?
はい。えっと、わかりやすくすると下のようなブロックのプログラムを作ってください。
x座標()、y座標()に()歩動かす::motion

shidaken wrote:

変数の使用はOKですか?
OKです。

Last edited by ie_523 (June 25, 2025 10:57:19)

finalbacon
Scratcher
100+ posts

Scratchスクリプトクイズ

#3479
修正しました。
shidaken
Scratcher
38 posts

Scratchスクリプトクイズ

shidaken
Scratcher
38 posts

Scratchスクリプトクイズ

変数なしでできましたw
ie_523
Scratcher
100+ posts

Scratchスクリプトクイズ

#3486
まさか一行だったとは…すごいですね!ちょっと想定解を超えてるかもしれないです。
ie_523
Scratcher
100+ posts

Scratchスクリプトクイズ

ちなみに想定解はこちらです。
想定解

追記
#3490
あっ(恥)。共有しました。

Last edited by ie_523 (June 27, 2025 09:06:15)

ioqj
Scratcher
500+ posts

Scratchスクリプトクイズ

ie_523 wrote:

ちなみに想定解はこちらです。
想定解
共有されていないようです。
ie_523
Scratcher
100+ posts

Scratchスクリプトクイズ

(sorry, it seems I posted it by mistake.)

Last edited by ie_523 (June 27, 2025 09:07:50)

shidaken
Scratcher
38 posts

Scratchスクリプトクイズ

では問題を出させてもらいますね。任意のリストに任意の数値が入っているとき、それを1番めから小さい順に並べ替えるプログラムを作ってください。プロジェクト共有推奨
また、変数は使っても構いません

Last edited by shidaken (June 27, 2025 09:23:17)

ef_cudaran
Scratcher
93 posts

Scratchスクリプトクイズ

[hoge v]を(0)にする
<(hoge) = ([list v]の長さ::list)>まで繰り返す
もし<(hoge) = (0)>なら
[hoge v]を(1)ずつ変える
でなければ
もし<([list v]の(hoge)番目) > ([list v]の((hoge) + (1))番目)>なら
[hoge hoge v]を([list v]の(hoge)番目)にする
[list v]の(hoge)番目を([list v]の((hoge) + (1))番目)で置き換える
[list v]の((hoge) + (1))番目を(hoge hoge)で置き換える
[hoge v]を(-1)ずつ変える
でなければ
[hoge v]を(1)ずつ変える
end
end
end
ノームソートです。プロジェクト版も昔作りましたが、使い回しは反則だと思ったのでscratchblocksで表現しました。

Last edited by ef_cudaran (July 16, 2025 05:08:57)

shidaken
Scratcher
38 posts

Scratchスクリプトクイズ

正解です。
僕も一応作ったんですがO(n^2)になってしまいました。こちらの方がスマートですし良いと思います
リンクです https://scratch.mit.edu/projects/1192699716/

Last edited by shidaken (June 27, 2025 21:54:18)

yuito2013
Scratcher
500+ posts

Scratchスクリプトクイズ

変数が20の倍数かを調べるプログラムを作ってください。trueまたはfalseの返すものであれば
<(変数) = [true]>
でも構いません。なお、
(() を (0) で割った余り)
([world] の ()番目の文字)
は使えません。想定解は4ブロックです。今作ってる作品に使用中ですので、できます。
U-Y-Scratch
Scratcher
500+ posts

Scratchスクリプトクイズ

yuito2013 wrote:

なお、
(() を (0) で割った余り)
は使えません。
確かに、
<((x) を (20) で割った余り) = [0]>
これができると秒◯ですね。
syhisa5656
Scratcher
35 posts

Scratchスクリプトクイズ

yuito2013 wrote:

変数が20の倍数かを調べるプログラムを作ってください。trueまたはfalseの返すものであれば
<(変数) = [true]>
でも構いません。なお、
(() を (0) で割った余り)
([world] の ()番目の文字)
は使えません。想定解は4ブロックです。今作ってる作品に使用中ですので、できます。
set [変数2 v] to ((変数) / (20))
set [変数3 v] to <(変数2) = ((変数) / (20)の切り捨て::operators)>
でできます。
返り値は変数3がfalseまたはtrueで出てきます。
Ke0
Scratcher
1000+ posts

Scratchスクリプトクイズ

( (() / (0))  の切り下げ::operators)
という話でしょう(切り下げは絶対値ブロックから変更できます)
abee
Scratcher
1000+ posts

Scratchスクリプトクイズ

#3495
(((変数) * (9)) の [sin v]::operators) = [0]
でどうでしょう。

Last edited by abee (July 9, 2025 08:24:51)

Catapult-
Scratcher
100+ posts

Scratchスクリプトクイズ

#3495
<not <((変数) / (20)) contains [.]?>>
tuneninemuihito
Scratcher
62 posts

Scratchスクリプトクイズ

shidaken wrote:

では問題を出させてもらいますね。任意のリストに任意の数値が入っているとき、それを1番めから小さい順に並べ替えるプログラムを作ってください。プロジェクト共有推奨
また、変数は使っても構いません

バブルソート
(Lが入力リスト)

(L :: list)

set [a v] to [0]
set [b v] to []
repeat ((length of [L v] :: list) - (1))
change [a v] by (1)
set [b v] to [0]
repeat ((length of [a v] :: list) - (a))
change [b v] by (1)
if <(item (b) of [list v] :: list) > (item ((b)+(1)) of [list v] :: list)> then
insert (item ((b)+(1)) of [list v] :: list) at (b) of [L v]
delete ((b) + (2)) of [L v]
end
end
end

多分あってる

Last edited by tuneninemuihito (July 15, 2025 15:07:08)

ba2eChi16
Scratcher
40 posts

Scratchスクリプトクイズ

#3495
<((foo) / (20)) = (((foo) / (20))の[絶対値 v]

これでどうでしょう。

Powered by DjangoBB