5.62 · exercise

Are these dice loaded?

Someone swears their die is fair. Read their rolls and draw a histogram, a bar chart with one bar per face, to check.

The starter's main reads numbers until the input runs out. Finish the tally: a roll from 1 to 6 adds 1 to that face's count in the .bss array tally (face 1 at index 0), and any other value adds 1 to ignored_r instead. Then finish the chart: the starter already prints each row's label f | and its line break, so print one # per roll in between.

tally holds ints, 4 bytes each, so entry i sits at tally + i * 4: the scaled form [tally_r, w9, SXTW 2] does that multiply for you.

The starter's input draws:

1 |#
2 |#
3 |###
4 |
5 |#
6 |###
ignored 0

What is checked

  • the chart above
  • the program exits with status 0
  • the same checks on other inputs the checker keeps hidden: no rolls at all, values outside 1 to 6 (0, 7 and negatives), and a die that only ever rolls one face
  • the counts are kept in memory (str)

specification

stdin3 6 1 3 5 6 6 2 3
stdoutprints the right output
exitexits with the right code
sourceuses str
hiddenright output and exit code on 4 more inputs you do not see

We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.

loading editor...

regfile

N clearZ clearC clearV clear

x0–x30 are the integer registers.

X0arg00x0000000000000000
X1arg10x0000000000000000
X2arg20x0000000000000000
X3arg30x0000000000000000
X4arg40x0000000000000000
X5arg50x0000000000000000
X6arg60x0000000000000000
X7arg70x0000000000000000
X8ind0x0000000000000000
X90x0000000000000000
X100x0000000000000000
X110x0000000000000000
X120x0000000000000000
X130x0000000000000000
X140x0000000000000000
X150x0000000000000000
X16ip00x0000000000000000
X17ip10x0000000000000000
X18pr0x0000000000000000
X190x0000000000000000
X200x0000000000000000
X210x0000000000000000
X220x0000000000000000
X230x0000000000000000
X240x0000000000000000
X250x0000000000000000
X260x0000000000000000
X270x0000000000000000
X280x0000000000000000
X29fp0x0000000000000000
X30lr0x0000000000000000
SP0x0000000080000000
PC0x0000000000400000
console

Output prints here as your program runs.

Press step or run under the editor, or feed stdin from the box below.

not assembled

Open in playground